From: Gisle Aas Date: Sat, 4 Jul 1998 00:49:42 +0000 (+0200) Subject: simplify xhv_array sizing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0c5b80af98159ce0a56841f0a002e78a266b5f09;p=p5sagit%2Fp5-mst-13.2.git simplify xhv_array sizing Subject: Re: [PATCH] Re: perl5.004_69 core dump Message-ID: p4raw-id: //depot/perl@1304 --- diff --git a/hv.c b/hv.c index 3966b1f..918640e 100644 --- a/hv.c +++ b/hv.c @@ -669,9 +669,6 @@ hsplit(HV *hv) register HE **b; register HE *entry; register HE **oentry; -#ifndef STRANGE_MALLOC - I32 tmp; -#endif nomemok = TRUE; #if defined(STRANGE_MALLOC) || defined(MYMALLOC) @@ -681,15 +678,8 @@ hsplit(HV *hv) return; } #else - i = newsize * sizeof(HE*); #define MALLOC_OVERHEAD 16 - tmp = MALLOC_OVERHEAD; - while (tmp - MALLOC_OVERHEAD < i) - tmp += tmp; - tmp -= MALLOC_OVERHEAD; - tmp /= sizeof(HE*); - assert(tmp >= newsize); - New(2,a, tmp, HE*); + New(2, a, newsize*sizeof(HE*) * 2 - MALLOC_OVERHEAD, char); if (!a) { nomemok = FALSE; return; @@ -762,14 +752,7 @@ hv_ksplit(HV *hv, IV newmax) return; } #else - i = newsize * sizeof(HE*); - j = MALLOC_OVERHEAD; - while (j - MALLOC_OVERHEAD < i) - j += j; - j -= MALLOC_OVERHEAD; - j /= sizeof(HE*); - assert(j >= newsize); - New(2, a, j, HE*); + New(2, a, newsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD, char); if (!a) { nomemok = FALSE; return; @@ -786,7 +769,11 @@ hv_ksplit(HV *hv, IV newmax) Zero(&a[oldsize], newsize-oldsize, HE*); /* zero 2nd half*/ } else { +#if defined(STRANGE_MALLOC) || defined(MYMALLOC) Newz(0, a, newsize, HE*); +#else + Newz(0, a, newsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD, char); +#endif } xhv->xhv_max = --newsize; xhv->xhv_array = (char*)a;