summaryrefslogtreecommitdiffstats
path: root/intl/vasnprintf.h
diff options
context:
space:
mode:
authorClaudio Fontana <sick_soul@users.sourceforge.net>2005-12-11 03:16:26 +0000
committerClaudio Fontana <sick_soul@users.sourceforge.net>2005-12-11 03:16:26 +0000
commitf882440b3724bcb442f3aaed65316a1671c35db0 (patch)
treebbc72a9eabe7dedd2c5cecca7b6fac6e77034229 /intl/vasnprintf.h
parent80e3f00037547654fc1aca601235936475a319b4 (diff)
downloadidutils-f882440b3724bcb442f3aaed65316a1671c35db0.tar.gz
idutils-f882440b3724bcb442f3aaed65316a1671c35db0.tar.bz2
idutils-f882440b3724bcb442f3aaed65316a1671c35db0.zip
* updated libintl
Diffstat (limited to 'intl/vasnprintf.h')
-rw-r--r--intl/vasnprintf.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/intl/vasnprintf.h b/intl/vasnprintf.h
index 65f1bc1..e67b88d 100644
--- a/intl/vasnprintf.h
+++ b/intl/vasnprintf.h
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
+ Copyright (C) 2002-2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
@@ -13,7 +13,7 @@
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
#ifndef _VASNPRINTF_H
@@ -48,7 +48,24 @@ extern "C" {
If successful, return the address of the string (this may be = RESULTBUF
if no dynamic memory allocation was necessary) and set *LENGTHP to the
number of resulting bytes, excluding the trailing NUL. Upon error, set
- errno and return NULL. */
+ errno and return NULL.
+
+ When dynamic memory allocation occurs, the preallocated buffer is left
+ alone (with possibly modified contents). This makes it possible to use
+ a statically allocated or stack-allocated buffer, like this:
+
+ char buf[100];
+ size_t len = sizeof (buf);
+ char *output = vasnprintf (buf, &len, format, args);
+ if (output == NULL)
+ ... error handling ...;
+ else
+ {
+ ... use the output string ...;
+ if (output != buf)
+ free (output);
+ }
+ */
extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)