- new_arena = mmap(arena->p, len,
- PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_PRIVATE,
- -1, 0);
+ if (!arena->p)
+ new_arena = mmap(arena->p, len,
+ PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_PRIVATE,
+ -1, 0);
+ else
+ new_arena = mremap(arena->p, arena->len,
+ len, MREMAP_MAYMOVE);
+ assert(new_arena != MAP_FAILED);
+