summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av.c7
-rw-r--r--handy.h2
-rw-r--r--perl.h6
-rw-r--r--sv.c10
4 files changed, 16 insertions, 9 deletions
diff --git a/av.c b/av.c
index cf95d6164a..4b3b08d9e3 100644
--- a/av.c
+++ b/av.c
@@ -117,8 +117,9 @@ Perl_av_extend(pTHX_ AV *av, I32 key)
IV itmp;
#endif
-#ifdef MYMALLOC
- newmax = malloced_size((void*)AvALLOC(av))/sizeof(SV*) - 1;
+#ifdef Perl_safesysmalloc_size
+ newmax = Perl_safesysmalloc_size((void*)AvALLOC(av)) /
+ sizeof(SV*) - 1;
if (key <= newmax)
goto resized;
@@ -147,7 +148,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key)
Safefree(AvALLOC(av));
AvALLOC(av) = ary;
#endif
-#ifdef MYMALLOC
+#ifdef Perl_safesysmalloc_size
resized:
#endif
ary = AvALLOC(av) + AvMAX(av) + 1;
diff --git a/handy.h b/handy.h
index 433fe134bb..008141ef3e 100644
--- a/handy.h
+++ b/handy.h
@@ -177,7 +177,7 @@ typedef U64TYPE U64;
#endif
/* HMB H.Merijn Brand - a placeholder for preparing Configure patches */
-#if defined(HAS_MALLOC_SIZE) && defined(LOCALTIME_R_NEEDS_TZSET) && defined(HAS_PSEUDOFORK) && defined(USE_DTRACE)
+#if defined(LOCALTIME_R_NEEDS_TZSET) && defined(HAS_PSEUDOFORK) && defined(USE_DTRACE)
/* Not (yet) used at top level, but mention them for metaconfig */
#endif
diff --git a/perl.h b/perl.h
index 7ad31768f0..aec1e263a4 100644
--- a/perl.h
+++ b/perl.h
@@ -4071,6 +4071,12 @@ struct perl_memory_debug_header {
# define INIT_TRACK_MEMPOOL(header, interp)
#endif
+#ifdef MYMALLOC
+# define Perl_safesysmalloc_size(where) Perl_malloced_size(where)
+#else if defined(HAS_MALLOC_SIZE)
+# define Perl_safesysmalloc_size(where) \
+ (malloc_size(((char *)(where)) - sTHX) - sTHX)
+#endif
typedef int (CPERLscope(*runops_proc_t)) (pTHX);
typedef void (CPERLscope(*share_proc_t)) (pTHX_ SV *sv);
diff --git a/sv.c b/sv.c
index 79fa25e67a..bde31e1abd 100644
--- a/sv.c
+++ b/sv.c
@@ -1492,11 +1492,11 @@ Perl_sv_grow(pTHX_ register SV *const sv, register STRLEN newlen)
}
}
SvPV_set(sv, s);
-#ifdef MYMALLOC
+#ifdef Perl_safesysmalloc_size
/* Do this here, do it once, do it right, and then we will never get
called back into sv_grow() unless there really is some growing
needed. */
- SvLEN_set(sv, malloced_size(s));
+ SvLEN_set(sv, Perl_safesysmalloc_size(s));
#else
SvLEN_set(sv, newlen);
#endif
@@ -4176,7 +4176,7 @@ Perl_sv_usepvn_flags(pTHX_ SV *sv, char *ptr, STRLEN len, U32 flags)
allocate = (flags & SV_HAS_TRAILING_NUL)
? len + 1 :
-#ifdef MYMALLOC
+#ifdef Perl_safesysmalloc_size
len + 1;
#else
PERL_STRLEN_ROUNDUP(len + 1);
@@ -4196,8 +4196,8 @@ Perl_sv_usepvn_flags(pTHX_ SV *sv, char *ptr, STRLEN len, U32 flags)
ptr = (char*) saferealloc (ptr, allocate);
#endif
}
-#ifdef MYMALLOC
- SvLEN_set(sv, malloced_size(ptr));
+#ifdef Perl_safesysmalloc_size
+ SvLEN_set(sv, Perl_safesysmalloc_size(ptr));
#else
SvLEN_set(sv, allocate);
#endif