diff options
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r-- | erts/emulator/beam/utils.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index c162395159..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. @@ -3982,6 +3984,14 @@ erts_write_env(char *key, char *value) return res; } +/* + * To be used to silence unused result warnings, but do not abuse it. + */ +void erts_silence_warn_unused_result(long unused) +{ + +} + #ifdef DEBUG /* * Handy functions when using a debugger - don't use in the code! |