diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 20:44:37 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 20:44:37 +0000 |
commit | 206dce7bab107651aa56dda8559b44958dc34a66 (patch) | |
tree | c7934586569e77a9aaf45f462e6d81b17b8ac7f2 /lib/heap.h | |
parent | 0f295221cac3cfe507cafa6cbf012c51537ce1c8 (diff) | |
download | ovm-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.h | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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 |