Jan Hubicka <jh@suse.cz>
Jan Hubicka <jh@suse.cz> * vasprintf.c (int_vasprintf): Pass va_list by value. Use va_copy for copying va_list. (vasprintf): Pass va_list by value. From-SVN: r73098
This commit is contained in:
parent
00d4a6d40e
commit
27eb8ab145
@ -1,3 +1,10 @@
|
|||||||
|
2003-10-30 Josef Zlomek <zlomekj@suse.cz>
|
||||||
|
|
||||||
|
Jan Hubicka <jh@suse.cz>
|
||||||
|
* 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 <zlomekj@suse.cz>
|
2003-10-30 Josef Zlomek <zlomekj@suse.cz>
|
||||||
|
|
||||||
* hashtab.c (htab_find_slot_with_hash): Decrease n_deleted
|
* hashtab.c (htab_find_slot_with_hash): Decrease n_deleted
|
||||||
|
@ -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
|
static int
|
||||||
int_vasprintf (result, format, args)
|
int_vasprintf (result, format, args)
|
||||||
char **result;
|
char **result;
|
||||||
const char *format;
|
const char *format;
|
||||||
va_list *args;
|
va_list args;
|
||||||
{
|
{
|
||||||
const char *p = format;
|
const char *p = format;
|
||||||
/* Add one to make sure that it is never zero, which might cause malloc
|
/* 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;
|
int total_width = strlen (format) + 1;
|
||||||
va_list ap;
|
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')
|
while (*p != '\0')
|
||||||
{
|
{
|
||||||
@ -135,12 +139,15 @@ int_vasprintf (result, format, args)
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef va_copy
|
||||||
|
va_end (ap);
|
||||||
|
#endif
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
global_total_width = total_width;
|
global_total_width = total_width;
|
||||||
#endif
|
#endif
|
||||||
*result = (char *) malloc (total_width);
|
*result = (char *) malloc (total_width);
|
||||||
if (*result != NULL)
|
if (*result != NULL)
|
||||||
return vsprintf (*result, format, *args);
|
return vsprintf (*result, format, args);
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -155,7 +162,7 @@ vasprintf (result, format, args)
|
|||||||
va_list args;
|
va_list args;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return int_vasprintf (result, format, &args);
|
return int_vasprintf (result, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
|
Loading…
Reference in New Issue
Block a user