diff options
author | Ilya Zakharevich <ilya@math.ohio-state.edu> | 1996-12-22 02:48:58 -0500 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1996-12-23 12:58:58 +1200 |
commit | c2a5c2d2fe03e66800c4332bfae5601c4d25896f (patch) | |
tree | 70cd49f7d9f9547a28f9f8e4b072e0c9dfc02e63 /malloc.c | |
parent | 579cf2c30d1c2eed351c0a6945d08a57bdcd1f6b (diff) | |
download | perl-c2a5c2d2fe03e66800c4332bfae5601c4d25896f.tar.gz |
malloc.c patch
I sent this before, but it slipped through the cracks:
currently TWO_POT_OPTIMIZE and DEBUGGING together
lead to "assertion botched" panics for allocations between 64K and
68K (this is not motorola-related ;-).
Enjoy,
p5p-msgid: <199612220748.CAA07164@monk.mps.ohio-state.edu>
Diffstat (limited to 'malloc.c')
-rw-r--r-- | malloc.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -78,9 +78,14 @@ static int findbucket _((union overhead *freep, int srchlen)); #define MAGIC 0xff /* magic # on accounting info */ #define RMAGIC 0x55555555 /* magic # on range info */ #ifdef RCHECK -#define RSLOP sizeof (u_int) +# define RSLOP sizeof (u_int) +# ifdef TWO_POT_OPTIMIZE +# define MAX_SHORT_BUCKET 12 +# else +# define MAX_SHORT_BUCKET 13 +# endif #else -#define RSLOP 0 +# define RSLOP 0 #endif #ifdef PACK_MALLOC @@ -265,7 +270,7 @@ malloc(nbytes) register MEM_SIZE shiftr; #ifdef PERL_CORE -#ifdef DEBUGGING +#if defined(DEBUGGING) || defined(RCHECK) MEM_SIZE size = nbytes; #endif @@ -344,6 +349,7 @@ malloc(nbytes) * Record allocated size of block and * bound space with magic numbers. */ + nbytes = (size + M_OVERHEAD + 3) &~ 3; if (nbytes <= 0x10000) p->ov_size = nbytes - 1; p->ov_rmagic = RMAGIC; @@ -515,7 +521,7 @@ free(mp) #endif #ifdef RCHECK ASSERT(op->ov_rmagic == RMAGIC); - if (OV_INDEX(op) <= 13) + if (OV_INDEX(op) <= MAX_SHORT_BUCKET) ASSERT(*(u_int *)((caddr_t)op + op->ov_size + 1 - RSLOP) == RMAGIC); op->ov_rmagic = RMAGIC - 1; #endif @@ -619,7 +625,7 @@ realloc(mp, nbytes) * Record new allocated size of block and * bound space with magic numbers. */ - if (OV_INDEX(op) <= 13) { + if (OV_INDEX(op) <= MAX_SHORT_BUCKET) { /* * Convert amount of memory requested into * closest block size stored in hash buckets |