# HG changeset patch # User Bruno Haible # Date 1157457400 0 # Node ID 6cfed75301b5c91f07b28d4db667fb78a161da34 # Parent 58ebe5a656c7b74f661508dfb796be0548a7ebd6 (iconv_alloc): Realloc the final result, to throw away unused memory. diff --git a/lib/iconvme.c b/lib/iconvme.c --- a/lib/iconvme.c +++ b/lib/iconvme.c @@ -253,7 +253,16 @@ } # 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)