Re: coderefs in @INC
[p5sagit/p5-mst-13.2.git] / malloc.c
index eee4da6..3a19be4 100644 (file)
--- a/malloc.c
+++ b/malloc.c
 #  ifndef warn
 #    define warn(mess, arg) fprintf(stderr, (mess), (arg))
 #  endif 
-#  ifndef warn
+#  ifndef warn2
 #    define warn2(mess, arg1) fprintf(stderr, (mess), (arg1), (arg2))
 #  endif 
 #  ifdef DEBUG_m
 #  ifndef pTHX
 #     define pTHX              void
 #     define pTHX_
-#     define dTHX              extern int Perl___notused
+#     ifdef HASATTRIBUTE
+#        define dTHX           extern int Perl___notused PERL_UNUSED_DECL
+#     else
+#        define dTHX            extern int Perl___notused
+#     endif
 #     define WITH_THX(s)       s
 #  endif
 #  ifndef PERL_GET_INTERP
 #  undef DEBUG_m
 #  define DEBUG_m(a)  \
     STMT_START {                                                       \
-       if (PERL_GET_INTERP) { dTHX; if (PL_debug & 128) { a; } }       \
+       if (PERL_GET_INTERP) { dTHX; if (DEBUG_m_TEST) { a; } } \
     } STMT_END
 #endif
 
@@ -886,16 +890,12 @@ static    union overhead *nextf[NBUCKETS];
 #endif
 
 #ifdef USE_PERL_SBRK
-#define sbrk(a) Perl_sbrk(a)
+# define sbrk(a) Perl_sbrk(a)
 Malloc_t Perl_sbrk (int size);
-#else 
-#ifdef DONT_DECLARE_STD
-#ifdef I_UNISTD
-#include <unistd.h>
-#endif
 #else
+# ifndef HAS_SBRK_PROTO /* <unistd.h> usually takes care of this */
 extern Malloc_t sbrk(int);
-#endif
+# endif
 #endif
 
 #ifdef DEBUGGING_MSTATS
@@ -1045,7 +1045,9 @@ Perl_malloc(register size_t nbytes)
            POW2_OPTIMIZE_ADJUST(nbytes);
            nbytes += M_OVERHEAD;
            nbytes = (nbytes + 3) &~ 3; 
+#if defined(PACK_MALLOC) && !defined(SMALL_BUCKET_VIA_TABLE)
          do_shifts:
+#endif
            shiftr = (nbytes - 1) >> START_SHIFT;
            bucket = START_SHIFTS_BUCKET;
            /* apart from this loop, this is O(1) */
@@ -1100,7 +1102,7 @@ Perl_malloc(register size_t nbytes)
 
        DEBUG_m(PerlIO_printf(Perl_debug_log,
                              "0x%"UVxf": (%05lu) malloc %ld bytes\n",
-                             PTR2UV(p+1), (unsigned long)(PL_an++),
+                             PTR2UV(p), (unsigned long)(PL_an++),
                              (long)size));
 
        /* remove from linked list */
@@ -1590,12 +1592,12 @@ Perl_mfree(void *mp)
                {
                    dTHX;
                    if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC))
-                       Perl_warner(aTHX_ WARN_MALLOC, "%s free() ignored",
+                       Perl_warner(aTHX_ WARN_MALLOC, "%s free() ignored (RMAGIC, PERL_CORE)",
                                    ovp->ov_rmagic == RMAGIC - 1 ?
                                    "Duplicate" : "Bad");
                }
 #else
-               warn("%s free() ignored",
+               warn("%s free() ignored (RMAGIC)",
                    ovp->ov_rmagic == RMAGIC - 1 ? "Duplicate" : "Bad");
 #endif         
 #else
@@ -1603,7 +1605,7 @@ Perl_mfree(void *mp)
                {
                    dTHX;
                    if (!PERL_IS_ALIVE || !PL_curcop || ckWARN_d(WARN_MALLOC))
-                       Perl_warner(aTHX_ WARN_MALLOC, "%s", "Bad free() ignored");
+                       Perl_warner(aTHX_ WARN_MALLOC, "%s", "Bad free() ignored (PERL_CORE)");
                }
 #else
                warn("%s", "Bad free() ignored");