static HE* more_he _((void));
#endif
+#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
+# define ARRAY_ALLOC_BYTES(size) ( (size)*sizeof(HE*) )
+#else
+# define MALLOC_OVERHEAD 16
+# define ARRAY_ALLOC_BYTES(size) ( (size)*sizeof(HE*)*2 - MALLOC_OVERHEAD )
+#endif
+
STATIC HE*
new_he(void)
{
|| (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME))
#endif
)
- Newz(503,xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ Newz(503,xhv->xhv_array, ARRAY_ALLOC_BYTES(xhv->xhv_max + 1), char);
else
return 0;
}
|| (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME))
#endif
)
- Newz(503,xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ Newz(503,xhv->xhv_array, ARRAY_ALLOC_BYTES(xhv->xhv_max + 1), char);
else
return 0;
}
PERL_HASH(hash, key, klen);
if (!xhv->xhv_array)
- Newz(505, xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ Newz(505, xhv->xhv_array, ARRAY_ALLOC_BYTES(xhv->xhv_max + 1), char);
oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
i = 1;
PERL_HASH(hash, key, klen);
if (!xhv->xhv_array)
- Newz(505, xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ Newz(505, xhv->xhv_array, ARRAY_ALLOC_BYTES(xhv->xhv_max + 1), char);
oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
i = 1;
nomemok = TRUE;
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
- Renew(a, newsize * sizeof(HE*), char);
+ Renew(a, ARRAY_ALLOC_BYTES(newsize), char);
if (!a) {
nomemok = FALSE;
return;
}
#else
#define MALLOC_OVERHEAD 16
- New(2, a, newsize*sizeof(HE*) * 2 - MALLOC_OVERHEAD, char);
+ New(2, a, ARRAY_ALLOC_BYTES(newsize), char);
if (!a) {
nomemok = FALSE;
return;
}
Copy(xhv->xhv_array, a, oldsize * sizeof(HE*), char);
if (oldsize >= 64) {
- offer_nice_chunk(xhv->xhv_array,
- oldsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD);
+ offer_nice_chunk(xhv->xhv_array, ARRAY_ALLOC_BYTES(oldsize));
}
else
Safefree(xhv->xhv_array);
if (a) {
nomemok = TRUE;
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
- Renew(a, newsize * sizeof(HE*), char);
+ Renew(a, ARRAY_ALLOC_BYTES(newsize), char);
if (!a) {
nomemok = FALSE;
return;
}
#else
- New(2, a, newsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD, char);
+ New(2, a, ARRAY_ALLOC_BYTES(newsize), char);
if (!a) {
nomemok = FALSE;
return;
}
Copy(xhv->xhv_array, a, oldsize * sizeof(HE*), char);
if (oldsize >= 64) {
- offer_nice_chunk(xhv->xhv_array,
- oldsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD);
+ offer_nice_chunk(xhv->xhv_array, ARRAY_ALLOC_BYTES(oldsize));
}
else
Safefree(xhv->xhv_array);
Zero(&a[oldsize * sizeof(HE*)], (newsize-oldsize) * sizeof(HE*), char); /* zero 2nd half*/
}
else {
-#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
- Newz(0, a, newsize * sizeof(HE*), char);
-#else
- Newz(0, a, newsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD, char);
-#endif
+ Newz(0, a, ARRAY_ALLOC_BYTES(newsize), char);
}
xhv->xhv_max = --newsize;
xhv->xhv_array = a;
}
if (!xhv->xhv_array)
- Newz(506,xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ Newz(506,xhv->xhv_array, ARRAY_ALLOC_BYTES(xhv->xhv_max + 1), char);
if (entry)
entry = HeNEXT(entry);
while (!entry) {