From e1e020df18299c89d4fcb9cce728b6e24f24bfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Mon, 20 Apr 2020 01:33:28 -0300 Subject: Make gap buffer heap allocated --- page.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3