From: Nicholas Clark Date: Tue, 26 Feb 2008 19:55:33 +0000 (+0000) Subject: In Perl_sv_usepvn_flags(), with MYMALLOC, use the actual malloc()ed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5d487c263b0c0c7fb6c50dee3540f1838c4ab067;p=p5sagit%2Fp5-mst-13.2.git In Perl_sv_usepvn_flags(), with MYMALLOC, use the actual malloc()ed size for SvLEN(), rather than an estimate. p4raw-id: //depot/perl@33378 --- diff --git a/sv.c b/sv.c index 11e7739..79fa25e 100644 --- a/sv.c +++ b/sv.c @@ -4175,7 +4175,12 @@ Perl_sv_usepvn_flags(pTHX_ SV *sv, char *ptr, STRLEN len, U32 flags) #endif allocate = (flags & SV_HAS_TRAILING_NUL) - ? len + 1: PERL_STRLEN_ROUNDUP(len + 1); + ? len + 1 : +#ifdef MYMALLOC + len + 1; +#else + PERL_STRLEN_ROUNDUP(len + 1); +#endif if (flags & SV_HAS_TRAILING_NUL) { /* It's long enough - do nothing. Specfically Perl_newCONSTSUB is relying on this. */ @@ -4191,9 +4196,13 @@ Perl_sv_usepvn_flags(pTHX_ SV *sv, char *ptr, STRLEN len, U32 flags) ptr = (char*) saferealloc (ptr, allocate); #endif } - SvPV_set(sv, ptr); - SvCUR_set(sv, len); +#ifdef MYMALLOC + SvLEN_set(sv, malloced_size(ptr)); +#else SvLEN_set(sv, allocate); +#endif + SvCUR_set(sv, len); + SvPV_set(sv, ptr); if (!(flags & SV_HAS_TRAILING_NUL)) { ptr[len] = '\0'; }