aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--heap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/heap.c b/heap.c
index 586bdfc..3f4fb91 100644
--- a/heap.c
+++ b/heap.c
@@ -82,10 +82,11 @@ static uintptr_t align_address(
}
static void* heap_alloc_impl(Heap* h, int size) {
- int* header, * nh, s, f, i, as, p;
+ int* header, * nh, s, f, i, as, p, m;
i = 0;
as = size + sizeof *header;
p = 0;
+ m = sizeof *header - 1;
for (i = 0; i < h->blocks; i++) {
header = (int*)(h->buffer + p);
s = header[0];
@@ -94,7 +95,7 @@ static void* heap_alloc_impl(Heap* h, int size) {
if (f) {
/* There's no point creating blocks smaller than
* the header. */
- if (as < s - sizeof *header - 1) {
+ if (as < s - m) {
s -= as;
header[0] = (s << 1);
nh = (int*)(h->buffer + p + s);