2 Copyright (C) 1995 Free Software Foundation
4 This file is part of the GNU IO Library. This library is free
5 software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option)
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU CC; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 As a special exception, if you link this library with files
20 compiled with a GNU compiler to produce an executable, this does not cause
21 the resulting executable to be covered by the GNU General Public License.
22 This exception does not however invalidate any other reasons why
23 the executable file might be covered by the GNU General Public License. */
31 _IO_vasprintf (result_ptr
, format
, args
)
36 /* Initial size of the buffer to be used. Will be doubled each time an
38 const _IO_size_t init_string_size
= 100;
42 string
= ALLOC_BUF(init_string_size
);
45 _IO_init((_IO_FILE
*)&sf
, 0);
46 _IO_JUMPS((_IO_FILE
*)&sf
) = &_IO_str_jumps
;
47 _IO_str_init_static ((_IO_FILE
*)&sf
, string
, init_string_size
, string
);
48 sf
._f
._flags
&= ~_IO_USER_BUF
;
49 sf
._s
._allocate_buffer
= (_IO_alloc_type
)malloc
;
50 sf
._s
._free_buffer
= (_IO_free_type
)free
;
51 ret
= _IO_vfprintf((_IO_FILE
*)&sf
, format
, args
);
54 *result_ptr
= (char*)realloc(sf
._f
._IO_buf_base
,
55 (sf
._f
._IO_write_ptr
- sf
._f
._IO_write_base
) +1);
56 if (*result_ptr
== NULL
)
57 *result_ptr
= sf
._f
._IO_buf_base
;
58 (*result_ptr
)[sf
._f
._IO_write_ptr
-sf
._f
._IO_write_base
] = '\0';
61 weak_alias (_IO_vasprintf
, vasprintf
)