diff options
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r-- | erts/emulator/beam/utils.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 687e6fa67b..31efddc0f2 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -124,26 +124,28 @@ erts_heap_alloc(Process* p, Uint need) #endif /* FORCE_HEAP_FRAGS */ n = need; + bp = MBUF(p); + if (bp != NULL && need <= (bp->size - bp->used_size)) { + Eterm* ret = bp->mem + bp->used_size; + bp->used_size += need; + return ret; + } #ifdef DEBUG n++; #endif bp = (ErlHeapFragment*) ERTS_HEAP_ALLOC(ERTS_ALC_T_HEAP_FRAG, ERTS_HEAP_FRAG_SIZE(n)); -#ifdef DEBUG - n--; -#endif - -#if defined(DEBUG) - for (i = 0; i <= n; i++) { - bp->mem[i] = ERTS_HOLE_MARKER; - } -#elif defined(CHECK_FOR_HOLES) +#if defined(DEBUG) || defined(CHECK_FOR_HOLES) for (i = 0; i < n; i++) { bp->mem[i] = ERTS_HOLE_MARKER; } #endif +#ifdef DEBUG + n--; +#endif + /* * When we have created a heap fragment, we are no longer allowed * to store anything more on the heap. |