source: trunk/src/gcc/libiberty/vasprintf.c@ 1005

Last change on this file since 1005 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.6 KB
Line 
1/* Like vsprintf but provides a pointer to malloc'd storage, which must
2 be freed by the caller.
3 Copyright (C) 1994 Free Software Foundation, Inc.
4
5This file is part of the libiberty library.
6Libiberty is free software; you can redistribute it and/or
7modify it under the terms of the GNU Library General Public
8License as published by the Free Software Foundation; either
9version 2 of the License, or (at your option) any later version.
10
11Libiberty is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14Library General Public License for more details.
15
16You should have received a copy of the GNU Library General Public
17License along with libiberty; see the file COPYING.LIB. If
18not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24#include <ansidecl.h>
25#ifdef ANSI_PROTOTYPES
26#include <stdarg.h>
27#else
28#include <varargs.h>
29#endif
30#include <stdio.h>
31#ifdef HAVE_STRING_H
32#include <string.h>
33#endif
34#ifdef HAVE_STDLIB_H
35#include <stdlib.h>
36#else
37extern unsigned long strtoul ();
38extern PTR malloc ();
39#endif
40#include "libiberty.h"
41
42#ifdef TEST
43int global_total_width;
44#endif
45
46/*
47
48@deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args})
49
50Like @code{vsprintf}, but instead of passing a pointer to a buffer,
51you pass a pointer to a pointer. This function will compute the size
52of the buffer needed, allocate memory with @code{malloc}, and store a
53pointer to the allocated memory in @code{*@var{resptr}}. The value
54returned is the same as @code{vsprintf} would return. If memory could
55not be allocated, zero is returned and @code{NULL} is stored in
56@code{*@var{resptr}}.
57