summaryrefslogtreecommitdiff
path: root/page.c
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-24 15:35:29 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-24 15:35:29 -0300
commit7db6ffa2267a210cd7bbffa0c55f68656e396234 (patch)
tree8f9b42180b852e4046f7dad4bb661de39c4f6c28 /page.c
parenta1a381926626aa44e264cd24dbf35e26f3d52330 (diff)
downloadjet-7db6ffa2267a210cd7bbffa0c55f68656e396234.tar.gz
jet-7db6ffa2267a210cd7bbffa0c55f68656e396234.zip
Fix deleting first page corrupting page pointer
Diffstat (limited to 'page.c')
-rw-r--r--page.c8
1 files changed, 8 insertions, 0 deletions
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);
}