diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-06 00:08:10 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-06 00:08:10 -0300 |
commit | 1939bdea53948f22fe3afa62d5bc731400c6ee0a (patch) | |
tree | 823def9c2bf5cbe118055eb4e2a7f8ee7f1b9d7b /page.c | |
parent | e7117322149fdc0196acb49c2ae0ff32e2c299c0 (diff) | |
download | jet-1939bdea53948f22fe3afa62d5bc731400c6ee0a.tar.gz jet-1939bdea53948f22fe3afa62d5bc731400c6ee0a.zip |
Fix gap_end off by one
Diffstat (limited to 'page.c')
-rw-r--r-- | page.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -15,7 +15,7 @@ struct page { struct page *new_page() { struct page *result = malloc(sizeof(struct page)); result->gap_start = result->buffer; - result->gap_end = result->buffer + PAGE_SIZE - 1; + result->gap_end = result->buffer + PAGE_SIZE; result->next = 0; result->prev = 0; return result; @@ -23,7 +23,7 @@ struct page *new_page() { static inline void set_half_page_gap(struct page *page) { page->gap_start = page->buffer + PAGE_SIZE / 2; - page->gap_end = page->buffer + PAGE_SIZE - 1; + page->gap_end = page->buffer + PAGE_SIZE; } void split_page(struct page *first_half) { @@ -55,14 +55,14 @@ void delete_page(struct page *page) { void move_gap(struct page *page, int target) { while(target) { if (target > 0) { - page->gap_end++; *(page->gap_start) = *(page->gap_end); page->gap_start++; + page->gap_end++; target--; } else { + page->gap_end--; page->gap_start--; *(page->gap_end) = *(page->gap_start); - page->gap_end--; target++; } } |