From 82ac70607d5f90ee52756e0152759e369a60032f Mon Sep 17 00:00:00 2001 From: zlomek Date: Thu, 30 Oct 2003 20:18:13 +0000 Subject: [PATCH] Jan Hubicka * vasprintf.c (int_vasprintf): Pass va_list by value. Use va_copy for copying va_list. (vasprintf): Pass va_list by value. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73098 138bc75d-0d04-0410-961f-82ee72b054a4 --- libiberty/ChangeLog | 7 +++++++ libiberty/vasprintf.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 34f421e1949..0cfc57dd28a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,12 @@ 2003-10-30 Josef Zlomek + Jan Hubicka + * vasprintf.c (int_vasprintf): Pass va_list by value. + Use va_copy for copying va_list. + (vasprintf): Pass va_list by value. + +2003-10-30 Josef Zlomek + * hashtab.c (htab_find_slot_with_hash): Decrease n_deleted instead of increasing n_elements when inserting to deleted slot. diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c index 775260475cb..d3d4f3a1553 100644 --- a/libiberty/vasprintf.c +++ b/libiberty/vasprintf.c @@ -59,13 +59,13 @@ not be allocated, minus one is returned and @code{NULL} is stored in */ -static int int_vasprintf PARAMS ((char **, const char *, va_list *)); +static int int_vasprintf PARAMS ((char **, const char *, va_list)); static int int_vasprintf (result, format, args) char **result; const char *format; - va_list *args; + va_list args; { const char *p = format; /* Add one to make sure that it is never zero, which might cause malloc @@ -73,7 +73,11 @@ int_vasprintf (result, format, args) int total_width = strlen (format) + 1; va_list ap; - memcpy ((PTR) &ap, (PTR) args, sizeof (va_list)); +#ifdef va_copy + va_copy (ap, args); +#else + memcpy ((PTR) &ap, (PTR) &args, sizeof (va_list)); +#endif while (*p != '\0') { @@ -135,12 +139,15 @@ int_vasprintf (result, format, args) p++; } } +#ifdef va_copy + va_end (ap); +#endif #ifdef TEST global_total_width = total_width; #endif *result = (char *) malloc (total_width); if (*result != NULL) - return vsprintf (*result, format, *args); + return vsprintf (*result, format, args); else return -1; } @@ -155,7 +162,7 @@ vasprintf (result, format, args) va_list args; #endif { - return int_vasprintf (result, format, &args); + return int_vasprintf (result, format, args); } #ifdef TEST -- 2.11.4.GIT