OSDN Git Service

2003-09-22 Andrew Cagney <cagney@redhat.com>
[pf3gnuchains/gcc-fork.git] / libiberty / vasprintf.c
index d69dc32..7752604 100644 (file)
@@ -1,6 +1,6 @@
 /* Like vsprintf but provides a pointer to malloc'd storage, which must
    be freed by the caller.
-   Copyright (C) 1994 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2003 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -45,14 +45,14 @@ int global_total_width;
 
 /*
 
-@deftypefn Extension int vasprintf (char **@var{resptr}, char *@var{format}, va_list @var{args})
+@deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args})
 
 Like @code{vsprintf}, but instead of passing a pointer to a buffer,
 you pass a pointer to a pointer.  This function will compute the size
 of the buffer needed, allocate memory with @code{malloc}, and store a
 pointer to the allocated memory in @code{*@var{resptr}}.  The value
 returned is the same as @code{vsprintf} would return.  If memory could
-not be allocated, zero is returned and @code{NULL} is stored in
+not be allocated, minus one is returned and @code{NULL} is stored in
 @code{*@var{resptr}}.
 
 @end deftypefn
@@ -138,11 +138,11 @@ int_vasprintf (result, format, args)
 #ifdef TEST
   global_total_width = total_width;
 #endif
-  *result = malloc (total_width);
+  *result = (char *) malloc (total_width);
   if (*result != NULL)
     return vsprintf (*result, format, *args);
   else
-    return 0;
+    return -1;
 }
 
 int