diff options
-rw-r--r-- | av.c | 7 | ||||
-rw-r--r-- | handy.h | 2 | ||||
-rw-r--r-- | perl.h | 6 | ||||
-rw-r--r-- | sv.c | 10 |
4 files changed, 16 insertions, 9 deletions
@@ -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; @@ -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 @@ -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); @@ -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 |