diff -u MODULES.html.sh.v0 MODULES.html.sh
--- MODULES.html.sh.v0 2004-08-26 08:53:18.000000000 +0200
+++ MODULES.html.sh 2004-08-26 08:53:35.000000000 +0200
@@ -1558,6 +1558,7 @@
func_module fwriteerror
func_module vasnprintf
func_module vasprintf
+ func_module xvasprintf
func_end_table
element="Signal handling "
diff -u -p /dev/null lib/xasprintf.c
--- /dev/null 2004-08-22 18:57:10.000000000 +0200
+++ lib/xasprintf.c 2004-08-26 17:30:30.000000000 +0200
@@ -0,0 +1,35 @@
+/* vasprintf and asprintf with out-of-memory checking.
+ Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU 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, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+/* Specification. */
+#include "xvasprintf.h"
+
+int
+xasprintf (char **resultp, const char *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = xvasprintf (resultp, format, args);
+ va_end (args);
+ return result;
+}
diff -u -p /dev/null lib/xvasprintf.c
--- /dev/null 2004-08-22 18:57:10.000000000 +0200
+++ lib/xvasprintf.c 2004-08-26 17:30:21.000000000 +0200
@@ -0,0 +1,39 @@
+/* vasprintf and asprintf with out-of-memory checking.
+ Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU 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, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+/* Specification. */
+#include "xvasprintf.h"
+
+#include "vasprintf.h"
+
+#include
+
+int
+xvasprintf (char **resultp, const char *format, va_list args)
+{
+ int length;
+
+ length = vasprintf (resultp, format, args);
+ if (length < 0 && errno == ENOMEM)
+ xmalloc_die();
+
+ return length;
+}
diff -u /dev/null lib/xvasprintf.h
--- /dev/null 2004-08-22 18:57:10.000000000 +0200
+++ lib/xvasprintf.h 2004-08-26 08:50:58.000000000 +0200
@@ -0,0 +1,55 @@
+/* vasprintf and asprintf with out-of-memory checking.
+ Copyright (C) 2002-2003 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU 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, USA. */
+
+#ifndef _XVASPRINTF_H
+#define _XVASPRINTF_H
+
+/* Get va_list. */
+#include
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+# define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+ are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Write formatted output to a string dynamically allocated with malloc().
+ If the memory allocation succeeds, store the address of the string in
+ *RESULT and return the number of resulting bytes, excluding the trailing
+ NUL. Upon memory allocation error, call xalloc_die. On some other
+ error, return -1. */
+extern int xasprintf (char **result, const char *format, ...)
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+extern int xvasprintf (char **result, const char *format, va_list args)
+ __attribute__ ((__format__ (__printf__, 2, 0)));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _XVASPRINTF_H */
diff -u /dev/null modules/xvasprintf
--- /dev/null 2004-08-22 18:57:10.000000000 +0200
+++ modules/xvasprintf 2004-08-26 08:55:27.000000000 +0200
@@ -0,0 +1,22 @@
+Description:
+vasprintf and asprintf with out-of-memory checking.
+Also see xalloc-die.
+
+Files:
+lib/xvasprintf.h
+lib/xvasprintf.c
+lib/xasprintf.c
+
+Depends-on:
+vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += xvasprintf.h xvasprintf.c xasprintf.c
+
+Include:
+"xvasprintf.h"
+
+Maintainer:
+Oskar Liljeblad