From 757849cd93a9bc361a5113e3aaafe516773aad44 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 23 Nov 2013 22:23:52 -0500 Subject: [SV 40361] Don't use vsnprintf(), which is an ISO C99 function. * output.c (error, fatal, message): Take an extra argument specifying how many bytes are used by the formatted arguments. (get_buffer): New function that allocates the requested buffer size. Remove msc_vsnprintf(), vfmtconcat(), and fmtconcat() as unneeded. * makeint.h: Declare various helper macros for generating output. * *.c: Change all error(), fatal(), message() calls to use the macros, or pass the extra length argument directly. --- misc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index bc54ce6..8e1ad4d 100644 --- a/misc.c +++ b/misc.c @@ -219,7 +219,7 @@ xmalloc (unsigned int size) /* Make sure we don't allocate 0, for pre-ISO implementations. */ void *result = malloc (size ? size : 1); if (result == 0) - fatal (NILF, _("virtual memory exhausted")); + OUT_OF_MEM(); return result; } @@ -230,7 +230,7 @@ xcalloc (unsigned int size) /* Make sure we don't allocate 0, for pre-ISO implementations. */ void *result = calloc (size ? size : 1, 1); if (result == 0) - fatal (NILF, _("virtual memory exhausted")); + OUT_OF_MEM(); return result; } @@ -245,7 +245,7 @@ xrealloc (void *ptr, unsigned int size) size = 1; result = ptr ? realloc (ptr, size) : malloc (size); if (result == 0) - fatal (NILF, _("virtual memory exhausted")); + OUT_OF_MEM(); return result; } @@ -262,7 +262,7 @@ xstrdup (const char *ptr) #endif if (result == 0) - fatal (NILF, _("virtual memory exhausted")); + OUT_OF_MEM(); #ifdef HAVE_STRDUP return result; @@ -281,7 +281,7 @@ xstrndup (const char *str, unsigned int length) #ifdef HAVE_STRNDUP result = strndup (str, length); if (result == 0) - fatal (NILF, _("virtual memory exhausted")); + OUT_OF_MEM(); #else result = xmalloc (length + 1); if (length > 0) -- cgit v1.2.3