]> Savannah Git Hosting - gnulib.git/commitdiff
(iconv_alloc): Realloc the final result, to throw away unused memory. haible-private
authorBruno Haible <bruno@clisp.org>
Tue, 5 Sep 2006 11:56:40 +0000 (11:56 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 5 Sep 2006 11:56:40 +0000 (11:56 +0000)
lib/iconvme.c

index aa12d24adc7d37e03f59c528a531f2b4a79c8453..e920e3d461c312d78282deee1a9ac2dc473e7811 100644 (file)
@@ -253,7 +253,16 @@ again2:
     }
 # endif
 
-  *outp = '\0';
+  *outp++ = '\0';
+
+  /* Give away unused memory.  */
+  if (outp - dest < outbuf_size)
+    {
+      char *newdest = (char *) realloc (dest, outp - dest);
+
+      if (newdest != NULL)
+       dest = newdest;
+    }
 
 out:
   if (have_error)