From: Robin Barker Date: Tue, 24 Dec 1996 04:08:19 +0000 (+1200) Subject: Fix compilation errors when malloc.c used for x2p X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=043bf81409f10ec3af5da98074284c28ddb66628;p=p5sagit%2Fp5-mst-13.2.git Fix compilation errors when malloc.c used for x2p --- diff --git a/malloc.c b/malloc.c index ae02a2d..755fadf 100644 --- a/malloc.c +++ b/malloc.c @@ -269,20 +269,21 @@ malloc(nbytes) register int bucket = 0; register MEM_SIZE shiftr; -#ifdef PERL_CORE #if defined(DEBUGGING) || defined(RCHECK) MEM_SIZE size = nbytes; #endif +#ifdef PERL_CORE #ifdef HAS_64K_LIMIT if (nbytes > 0xffff) { - PerlIO_printf(PerlIO_stderr(), "Allocation too large: %lx\n", (long)nbytes); + PerlIO_printf(PerlIO_stderr(), + "Allocation too large: %lx\n", (long)nbytes); my_exit(1); } #endif /* HAS_64K_LIMIT */ #ifdef DEBUGGING if ((long)nbytes < 0) - croak("panic: malloc"); + croak("panic: malloc"); #endif #endif /* PERL_CORE */ @@ -293,20 +294,18 @@ malloc(nbytes) * space used per block for accounting. */ #ifdef PACK_MALLOC - if (nbytes > MAX_2_POT_ALGO) { + if (nbytes == 0) + nbytes = 1; + else if (nbytes > MAX_2_POT_ALGO) #endif + { #ifdef TWO_POT_OPTIMIZE - if (nbytes >= FIRST_BIG_BOUND) { - nbytes -= PERL_PAGESIZE; - } + if (nbytes >= FIRST_BIG_BOUND) + nbytes -= PERL_PAGESIZE; #endif - nbytes += M_OVERHEAD; - nbytes = (nbytes + 3) &~ 3; -#ifdef PACK_MALLOC - } else if (nbytes == 0) { - nbytes = 1; + nbytes += M_OVERHEAD; + nbytes = (nbytes + 3) &~ 3; } -#endif shiftr = (nbytes - 1) >> 2; /* apart from this loop, this is O(1) */ while (shiftr >>= 1) @@ -556,14 +555,15 @@ realloc(mp, nbytes) int was_alloced = 0; char *cp = (char*)mp; -#ifdef PERL_CORE #ifdef DEBUGGING MEM_SIZE size = nbytes; #endif +#ifdef PERL_CORE #ifdef HAS_64K_LIMIT if (nbytes > 0xffff) { - PerlIO_printf(PerlIO_stderr(), "Reallocation too large: %lx\n", size); + PerlIO_printf(PerlIO_stderr(), + "Reallocation too large: %lx\n", size); my_exit(1); } #endif /* HAS_64K_LIMIT */