diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-20 01:33:28 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-20 01:33:28 -0300 |
commit | e1e020df18299c89d4fcb9cce728b6e24f24bfff (patch) | |
tree | 8ec7f8e5ee5df7c5ace40fa7bd7b7eac01031436 /page.c | |
parent | ee409eba1a7b9812394df3a53bc41fb7998e28c6 (diff) | |
download | jet-e1e020df18299c89d4fcb9cce728b6e24f24bfff.tar.gz jet-e1e020df18299c89d4fcb9cce728b6e24f24bfff.zip |
Make gap buffer heap allocated
Diffstat (limited to 'page.c')
-rw-r--r-- | page.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -5,7 +5,7 @@ #define PAGE_SIZE 4096 struct page { - uint8_t buffer[PAGE_SIZE]; + uint8_t *buffer; uint16_t gap_start; uint16_t gap_end; struct page *next; @@ -14,6 +14,7 @@ struct page { struct page *new_page() { struct page *result = malloc(sizeof(struct page)); + result->buffer = malloc(PAGE_SIZE); result->gap_start = 0; result->gap_end = PAGE_SIZE; result->next = 0; @@ -51,6 +52,7 @@ void free_page(struct page **page) { } struct page *tmp = *page; *page = (*page)->prev ?: (*page)->next; + free(tmp->buffer); free(tmp); } |