Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37481473
en ru br
Репозитории ALT
S:1.11.23-alt9
5.1: 1.11.23-alt3.M50P.1
4.1: 1.11.22-alt3
4.0: 1.11.22-alt2
+updates:1.11.22-alt2
3.0: 1.11.20-alt1
www.altlinux.org/Changes

Группа :: Разработка/Прочее
Пакет: cvs

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: cvs-1.11.10-alt-xasprintf.patch
Скачать


diff -uprk.orig cvs-1.11.10.orig/src/cvs.h cvs-1.11.10/src/cvs.h
--- cvs-1.11.10.orig/src/cvs.h	2003-12-20 20:17:57 +0300
+++ cvs-1.11.10/src/cvs.h	2003-12-20 20:18:11 +0300
@@ -460,6 +460,8 @@ extern void check_numeric PROTO ((const 
 char *getcaller PROTO((void));
 char *time_stamp PROTO((char *file));
 
+extern char *xasprintf (char **ptr, const char *fmt, ...)
+	__attribute__ ((__format__ (__printf__, 2, 3)));
 void *xmalloc PROTO((size_t bytes));
 void *xrealloc PROTO((void *ptr, size_t bytes));
 void expand_string PROTO ((char **, size_t *, size_t));
diff -uprk.orig cvs-1.11.10.orig/src/subr.c cvs-1.11.10/src/subr.c
--- cvs-1.11.10.orig/src/subr.c	2003-12-20 20:17:56 +0300
+++ cvs-1.11.10/src/subr.c	2003-12-20 20:25:07 +0300
@@ -9,6 +9,7 @@
  */
 
 #include <assert.h>
+#include <stdarg.h>
 #include "cvs.h"
 #include "getline.h"
 
@@ -23,6 +24,19 @@
 
 extern char *getlogin ();
 
+char *
+xasprintf (char **ptr, const char *fmt, ...)
+{
+	va_list arg;
+
+	va_start (arg, fmt);
+	if (vasprintf (ptr, fmt, arg) < 0)
+		error (1, errno, "vasprintf");
+	va_end (arg);
+
+	return *ptr;
+}
+
 /*
  * malloc some data and die if it fails
  */
@@ -32,17 +46,11 @@ xmalloc (bytes)
 {
     char *cp;
 
-    /* Parts of CVS try to xmalloc zero bytes and then free it.  Some
-       systems have a malloc which returns NULL for zero byte
-       allocations but a free which can't handle NULL, so compensate. */
-    if (bytes == 0)
-	bytes = 1;
-
     cp = malloc (bytes);
     if (cp == NULL)
     {
 	char buf[80];
-	sprintf (buf, "out of memory; can not allocate %lu bytes",
+	sprintf (buf, "cannot allocate %lu bytes: out of memory",
 		 (unsigned long) bytes);
 	error (1, 0, buf);
     }
@@ -59,17 +67,12 @@ xrealloc (ptr, bytes)
     void *ptr;
     size_t bytes;
 {
-    char *cp;
-
-    if (!ptr)
-	cp = malloc (bytes);
-    else
-	cp = realloc (ptr, bytes);
+    char *cp = realloc (ptr, bytes);
 
     if (cp == NULL)
     {
 	char buf[80];
-	sprintf (buf, "out of memory; can not reallocate %lu bytes",
+	sprintf (buf, "can not reallocate %lu bytes: out of memory",
 		 (unsigned long) bytes);
 	error (1, 0, buf);
     }
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin