diff options
author | Gisle Aas <gisle@aas.no> | 1998-07-04 02:49:42 +0200 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-04 05:40:35 +0000 |
commit | 0c5b80af98159ce0a56841f0a002e78a266b5f09 (patch) | |
tree | 2e01fbc5f20bd0e461364feb03808663066a133d /hv.c | |
parent | 87c2f9c4716d6ca80eef0a77058013da1536e87d (diff) | |
download | perl-0c5b80af98159ce0a56841f0a002e78a266b5f09.tar.gz |
simplify xhv_array sizing
Subject: Re: [PATCH] Re: perl5.004_69 core dump
Message-ID: <m3yauav9bt.fsf@furu.g.aas.no>
p4raw-id: //depot/perl@1304
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -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; |