From 7db6ffa2267a210cd7bbffa0c55f68656e396234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Fri, 24 Apr 2020 15:35:29 -0300 Subject: Fix deleting first page corrupting page pointer --- page.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'page.c') diff --git a/page.c b/page.c index 1244df4..864623e 100644 --- a/page.c +++ b/page.c @@ -46,6 +46,13 @@ void split_page(struct page *back) { back->next = front; } +void copy_page(struct page *dest, struct page *src) { + memcpy(dest->elements, src->elements, PAGE_SIZE); + dest->gap_start = src->gap_start; + dest->gap_end = src->gap_end; + dest->element_count = src->element_count; +} + void free_page(struct page *page) { if (page->prev) { page->prev->next = page->next; @@ -53,6 +60,7 @@ void free_page(struct page *page) { if (page->next) { page->next->prev = page->prev; } + free(page->elements); free(page); } -- cgit v1.2.3