aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2010-02-11 13:30:32 +0000
committerErlang/OTP <[email protected]>2010-02-11 13:30:32 +0000
commit2a96208cb00220f963e723ae0530492c5c70df27 (patch)
tree1a0150d8a404a19fa69da48bb49fad95e701454c /erts/emulator/beam/utils.c
parent94a5a2832200fa5061d31e64c0eb8315c3215e0a (diff)
downloadotp-2a96208cb00220f963e723ae0530492c5c70df27.tar.gz
otp-2a96208cb00220f963e723ae0530492c5c70df27.tar.bz2
otp-2a96208cb00220f963e723ae0530492c5c70df27.zip
OTP-8335 Even more NIF features
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c20
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.