With loadfile() doing megabyte-sized trial-and-error allocations, we
want to be able to do really set the size on the final allocation;
thus constrain the amount of permitted slack to 4K max.
/* Add the obligatory arena header, and round up */
newsize = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
- if ( oldsize >= newsize && newsize >= (oldsize >> 2) ) {
+ if ( oldsize >= newsize && newsize >= (oldsize >> 2) &&
+ oldsize-newsize < 4096 ) {
/* This allocation is close enough already. */
return ptr;
} else {