]> gcc.gnu.org Git - gcc.git/blob - libiberty/asprintf.c
1cd63978037bb0114afe6b653c72265bcc84d496
[gcc.git] / libiberty / asprintf.c
1 /* Like sprintf but provides a pointer to malloc'd storage, which must
2 be freed by the caller.
3 Copyright (C) 1997 Free Software Foundation, Inc.
4 Contributed by Cygnus Solutions.
5
6 This file is part of the libiberty library.
7 Libiberty is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 Libiberty is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with libiberty; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #include "ansidecl.h"
23 #include "libiberty.h"
24
25 #if defined __STDC__ || defined ALMOST_STDC
26 #include <stdarg.h>
27 #else
28 #include <varargs.h>
29 #endif
30
31 /* VARARGS */
32 #ifdef ANSI_PROTOTYPES
33 int
34 asprintf (char **buf, const char *fmt, ...)
35 #else
36 int
37 asprintf (buf, fmt, va_alist)
38 char **buf;
39 const char *fmt;
40 va_dcl
41 #endif
42 {
43 int status;
44 va_list ap;
45 #ifdef ANSI_PROTOTYPES
46 va_start (ap, fmt);
47 #else
48 va_start (ap);
49 #endif
50 status = vasprintf (buf, fmt, ap);
51 va_end (ap);
52 return status;
53 }
This page took 0.037838 seconds and 4 git commands to generate.