diff options
Diffstat (limited to 'malloc.c')
-rw-r--r-- | malloc.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -332,6 +332,13 @@ } STMT_END #endif +#ifdef PERL_IMPLICIT_CONTEXT +# define PERL_IS_ALIVE aTHX +#else +# define PERL_IS_ALIVE TRUE +#endif + + /* * Layout of memory: * ~~~~~~~~~~~~~~~~ @@ -1513,11 +1520,22 @@ Perl_mfree(void *mp) if (!bad_free_warn) return; #ifdef RCHECK +#ifdef PERL_CORE + if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC)) + Perl_warner(WARN_MALLOC, "%s free() ignored", + ovp->ov_rmagic == RMAGIC - 1 ? "Duplicate" : "Bad"); +#else warn("%s free() ignored", ovp->ov_rmagic == RMAGIC - 1 ? "Duplicate" : "Bad"); +#endif +#else +#ifdef PERL_CORE + if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC)) + Perl_warner(WARN_MALLOC, "%s", "Bad free() ignored"); #else warn("%s", "Bad free() ignored"); #endif +#endif return; /* sanity */ } #ifdef RCHECK @@ -1595,12 +1613,24 @@ Perl_realloc(void *mp, size_t nbytes) if (!bad_free_warn) return Nullch; #ifdef RCHECK +#ifdef PERL_CORE + if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC)) + Perl_warner(WARN_MALLOC, "%srealloc() %signored", + (ovp->ov_rmagic == RMAGIC - 1 ? "" : "Bad "), + ovp->ov_rmagic == RMAGIC - 1 ? "of freed memory " : ""); +#else warn("%srealloc() %signored", (ovp->ov_rmagic == RMAGIC - 1 ? "" : "Bad "), ovp->ov_rmagic == RMAGIC - 1 ? "of freed memory " : ""); +#endif +#else +#ifdef PERL_CORE + if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC)) + Perl_warner(WARN_MALLOC, "%s", "Bad realloc() ignored"); #else warn("%s", "Bad realloc() ignored"); #endif +#endif return Nullch; /* sanity */ } |