changeset 7252:86ec317a7b82

(iconv_alloc): Don't assume that malloc() or realloc(), when failing, sets errno to ENOMEM. (malloc on GNU/kFreeBSD doesn't.)
author Bruno Haible <bruno@clisp.org>
date Tue, 05 Sep 2006 11:47:33 +0000
parents db39032b0043
children 203bb805f82b
files lib/iconvme.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/iconvme.c
+++ b/lib/iconvme.c
@@ -131,7 +131,10 @@
 
   outp = dest = (char *) malloc (outbuf_size);
   if (dest == NULL)
-    return NULL;
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
 
 again:
   err = iconv (cd, &p, &inbytes_remaining, &outp, &outbytes_remaining);
@@ -159,6 +162,7 @@
 	    newdest = (char *) realloc (dest, newsize);
 	    if (newdest == NULL)
 	      {
+		errno = ENOMEM;
 		have_error = 1;
 		goto out;
 	      }