2N/A/* vsprintf with automatic memory allocation. 2N/A Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. 2N/A This program is free software; you can redistribute it and/or modify 2N/A it under the terms of the GNU General Public License as published by 2N/A the Free Software Foundation; either version 3, or (at your option) 2N/A This program is distributed in the hope that it will be useful, 2N/A but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A GNU General Public License for more details. 2N/A You should have received a copy of the GNU General Public License along 2N/A with this program; if not, write to the Free Software Foundation, 2N/A Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 2N/A/* The __attribute__ feature is available in gcc versions 2.5 and later. 2N/A The __-protected variants of the attributes 'format' and 'printf' are 2N/A accepted by gcc versions 2.6.4 (effectively 2.7) and later. 2N/A We enable __attribute__ only if these are supported too, because 2N/A gnulib and libintl do '#define printf __printf__' when they override 2N/A the 'printf' function. */ 2N/A/* Write formatted output to a string dynamically allocated with malloc(). 2N/A You can pass a preallocated buffer for the result in RESULTBUF and its 2N/A size in *LENGTHP; otherwise you pass RESULTBUF = NULL. 2N/A If successful, return the address of the string (this may be = RESULTBUF 2N/A if no dynamic memory allocation was necessary) and set *LENGTHP to the 2N/A number of resulting bytes, excluding the trailing NUL. Upon error, set 2N/A errno and return NULL. 2N/A When dynamic memory allocation occurs, the preallocated buffer is left 2N/A alone (with possibly modified contents). This makes it possible to use 2N/A a statically allocated or stack-allocated buffer, like this: 2N/A size_t len = sizeof (buf); 2N/A char *output = vasnprintf (buf, &len, format, args); 2N/A ... error handling ...; 2N/A ... use the output string ...; 2N/A#
endif /* _VASNPRINTF_H */