Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/libiberty/asprintf.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    2323#include "libiberty.h"
    2424
    25 #if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC)
    26 #define USE_STDARG
    27 #endif
    28 
    29 #ifdef USE_STDARG
     25#ifdef ANSI_PROTOTYPES
    3026#include <stdarg.h>
    3127#else
     
    3329#endif
    3430
    35 /* VARARGS */
    36 #ifdef USE_STDARG
     31/*
     32
     33@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
     34
     35Like @code{sprintf}, but instead of passing a pointer to a buffer, you
     36pass a pointer to a pointer.  This function will compute the size of
     37the buffer needed, allocate memory with @code{malloc}, and store a
     38pointer to the allocated memory in @code{*@var{resptr}}.  The value
     39returned is the same as @code{sprintf} would return.  If memory could
     40not be allocated, zero is returned and @code{NULL} is stored in
     41@code{*@var{resptr}}.
     42
     43@end deftypefn
     44
     45*/
     46
    3747int
    38 asprintf (char **buf, const char *fmt, ...)
    39 #else
    40 int
    41 asprintf (buf, fmt, va_alist)
    42      char **buf;
    43      const char *fmt;
    44      va_dcl
    45 #endif
     48asprintf VPARAMS ((char **buf, const char *fmt, ...))
    4649{
    4750  int status;
    48   va_list ap;
    49 #ifdef USE_STDARG
    50   va_start (ap, fmt);
    51 #else
    52   va_start (ap);
    53 #endif
     51  VA_OPEN (ap, fmt);
     52  VA_FIXEDARG (ap, char **, buf);
     53  VA_FIXEDARG (ap, const char *, fmt);
    5454  status = vasprintf (buf, fmt, ap);
    55   va_end (ap);
     55  VA_CLOSE (ap);
    5656  return status;
    5757}
Note: See TracChangeset for help on using the changeset viewer.