aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/heap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/heap.c b/lib/heap.c
index 7dd7a12..28cb06a 100644
--- a/lib/heap.c
+++ b/lib/heap.c
@@ -12,6 +12,8 @@
#include "./heap.h"
+#include <stdio.h>
+
page_t *page_create(size_t max, page_t *next)
{
page_t *page = calloc(1, sizeof(*page) + max);
@@ -41,6 +43,8 @@ bool heap_free_page(heap_t *heap, page_t *page)
heap->beg = heap->beg->next;
page_delete(page);
--heap->pages;
+ if (heap->pages == 0)
+ heap->end = NULL;
return true;
}
@@ -63,6 +67,8 @@ bool heap_free_page(heap_t *heap, page_t *page)
heap->end = prev;
page_delete(page);
--heap->pages;
+ if (heap->pages == 0)
+ heap->beg = NULL;
return true;
}