summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-09-05 11:56:40 +0000
committerBruno Haible <bruno@clisp.org>2006-09-05 11:56:40 +0000
commit6465ba8523b1c434164303f98aacae946827ba6c (patch)
tree912ad735d21816a4f93770ed967fd8543d18a0fc
parent14ae15c4ee20a2d1a5aee09fceefc7cf8b1ca333 (diff)
downloadgnulib-6465ba8523b1c434164303f98aacae946827ba6c.tar.gz
(iconv_alloc): Realloc the final result, to throw away unused memory.haible-private
-rw-r--r--lib/iconvme.c11
1 files changed, 10 insertions, 1 deletions
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)