From: Bruno Haible Date: Tue, 5 Sep 2006 11:56:40 +0000 (+0000) Subject: (iconv_alloc): Realloc the final result, to throw away unused memory. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fhaible-private;p=gnulib.git (iconv_alloc): Realloc the final result, to throw away unused memory. --- diff --git a/lib/iconvme.c b/lib/iconvme.c index aa12d24adc..e920e3d461 100644 --- a/lib/iconvme.c +++ b/lib/iconvme.c @@ -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)