In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/2e11cf67d5f4d36fbbcd2b2e66dbc5bfb0fd7836?hp=1222ab91f6663819e940d74716fd36e292cd58fb>
- Log ----------------------------------------------------------------- commit 2e11cf67d5f4d36fbbcd2b2e66dbc5bfb0fd7836 Author: Karl Williamson <[email protected]> Date: Sat Oct 28 23:13:47 2017 -0600 bytes_to_utf8(): Trim unused malloc'd space I asked on p5p if anyone had an opinion about whether to trim overallocated space in this function, and got no replies. It seems to me to be best to tidy up upon return. ----------------------------------------------------------------------- Summary of changes: utf8.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utf8.c b/utf8.c index 8ffa5dd129..f6938f2554 100644 --- a/utf8.c +++ b/utf8.c @@ -2351,8 +2351,13 @@ Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *lenp) append_utf8_from_native_byte(*s, &d); s++; } + *d = '\0'; *lenp = d-dst; + + /* Trim unused space */ + Renew(dst, *lenp + 1, U8); + return dst; } -- Perl5 Master Repository
