From 3085dfeded22571f2b7a22aed43c1d2f00cfb28d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 28 Apr 2024 14:33:35 +0530 Subject: [PATCH] Added a PAGE_DEFAULT_SIZE so max can be set to 0 --- lib/heap.c | 3 +++ lib/heap.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/heap.c b/lib/heap.c index 28cb06a..a54e24a 100644 --- a/lib/heap.c +++ b/lib/heap.c @@ -16,6 +16,9 @@ page_t *page_create(size_t max, page_t *next) { + if (max == 0) + max = PAGE_DEFAULT_SIZE; + page_t *page = calloc(1, sizeof(*page) + max); page->available = max; page->next = next; diff --git a/lib/heap.h b/lib/heap.h index 97be975..c8db635 100644 --- a/lib/heap.h +++ b/lib/heap.h @@ -18,6 +18,8 @@ #include #include +#define PAGE_DEFAULT_SIZE 256 + typedef struct Page { struct Page *next;