summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-02-26 19:55:33 +0000
committerNicholas Clark <nick@ccl4.org>2008-02-26 19:55:33 +0000
commit5d487c263b0c0c7fb6c50dee3540f1838c4ab067 (patch)
tree7ed3c332f7542542d6a05ff5127e9d07bbce3324 /sv.c
parent98653f182f8d34d630c65229237c0d55f664e886 (diff)
downloadperl-5d487c263b0c0c7fb6c50dee3540f1838c4ab067.tar.gz
In Perl_sv_usepvn_flags(), with MYMALLOC, use the actual malloc()ed
size for SvLEN(), rather than an estimate. p4raw-id: //depot/perl@33378
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index 11e7739901..79fa25e67a 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';
}