summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-20 01:33:28 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-20 01:33:28 -0300
commite1e020df18299c89d4fcb9cce728b6e24f24bfff (patch)
tree8ec7f8e5ee5df7c5ace40fa7bd7b7eac01031436
parentee409eba1a7b9812394df3a53bc41fb7998e28c6 (diff)
downloadjet-e1e020df18299c89d4fcb9cce728b6e24f24bfff.tar.gz
jet-e1e020df18299c89d4fcb9cce728b6e24f24bfff.zip
Make gap buffer heap allocated
-rw-r--r--page.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/page.c b/page.c
index edc8bc7..59b1701 100644
--- a/page.c
+++ b/page.c
@@ -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);
}