[proposed PATCH] correctly unlocalise exists on tied/%ENV
[p5sagit/p5-mst-13.2.git] / malloc.c
index 450b6a2..aafe41d 100644 (file)
--- a/malloc.c
+++ b/malloc.c
 
 #ifdef DEBUGGING
 #  undef DEBUG_m
-#  define DEBUG_m(a)  \
+#  define DEBUG_m(a)                                                   \
     STMT_START {                                                       \
-       if (PERL_GET_INTERP) { dTHX; if (DEBUG_m_TEST) { a; } } \
+       if (PERL_GET_INTERP) {                                          \
+           dTHX;                                                       \
+           if (DEBUG_m_TEST) {                                         \
+               PL_debug &= ~DEBUG_m_FLAG;                              \
+               a;                                                      \
+               PL_debug |= DEBUG_m_FLAG;                               \
+           }                                                           \
+       }                                                               \
     } STMT_END
 #endif
 
@@ -1103,11 +1110,6 @@ Perl_malloc(register size_t nbytes)
                return (NULL);
        }
 
-       DEBUG_m(PerlIO_printf(Perl_debug_log,
-                             "0x%"UVxf": (%05lu) malloc %ld bytes\n",
-                             PTR2UV(p), (unsigned long)(PL_an++),
-                             (long)size));
-
        /* remove from linked list */
 #if defined(RCHECK)
        if ((PTR2UV(p)) & (MEM_ALIGNBYTES - 1)) {
@@ -1128,6 +1130,11 @@ Perl_malloc(register size_t nbytes)
 
        MALLOC_UNLOCK;
 
+       DEBUG_m(PerlIO_printf(Perl_debug_log,
+                             "0x%"UVxf": (%05lu) malloc %ld bytes\n",
+                             PTR2UV(p), (unsigned long)(PL_an++),
+                             (long)size));
+
 #ifdef IGNORE_SMALL_BAD_FREE
        if (bucket >= FIRST_BUCKET_WITH_CHECK)
 #endif