aboutsummaryrefslogtreecommitdiff
path: root/lib/heap.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 20:44:37 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 20:44:37 +0000
commit206dce7bab107651aa56dda8559b44958dc34a66 (patch)
treec7934586569e77a9aaf45f462e6d81b17b8ac7f2 /lib/heap.h
parent0f295221cac3cfe507cafa6cbf012c51537ce1c8 (diff)
downloadovm-206dce7bab107651aa56dda8559b44958dc34a66.tar.gz
ovm-206dce7bab107651aa56dda8559b44958dc34a66.tar.bz2
ovm-206dce7bab107651aa56dda8559b44958dc34a66.zip
Heap now maintains a new page per allocation
Instead of having each page be an area of memory, where multiple pointers to differing data may lie, we instead have each page being one allocation. This ensures that a deletion algorithm, as provided, would actually work without destroying older pointers which may have been allocated. Great!
Diffstat (limited to 'lib/heap.h')
-rw-r--r--lib/heap.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/heap.h b/lib/heap.h
index b84baf0..d289ffa 100644
--- a/lib/heap.h
+++ b/lib/heap.h
@@ -17,17 +17,14 @@
#include <stdlib.h>
-#define PAGE_DEFAULT_SIZE 64
-
typedef struct Page
{
struct Page *next;
- size_t used, available;
+ size_t available;
byte data[];
} page_t;
page_t *page_create(size_t, page_t *);
-size_t page_space_left(page_t *);
void page_delete(page_t *);
typedef struct
@@ -37,7 +34,8 @@ typedef struct
} heap_t;
void heap_create(heap_t *);
-byte *heap_allocate(heap_t *, size_t);
+void heap_free_page(heap_t *, page_t *);
+page_t *heap_allocate(heap_t *, size_t);
void heap_stop(heap_t *);
#endif