summaryrefslogtreecommitdiff
path: root/point.c
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-26 00:19:13 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-26 00:19:13 -0300
commitef4d419989bcfe39f7ea7e50d4945c0ae24f2e85 (patch)
tree3b26682a8cbb18ba8d921d7f3d62aaaf73f3ee70 /point.c
parent7db6ffa2267a210cd7bbffa0c55f68656e396234 (diff)
downloadjet-ef4d419989bcfe39f7ea7e50d4945c0ae24f2e85.tar.gz
jet-ef4d419989bcfe39f7ea7e50d4945c0ae24f2e85.zip
Fix element queries at page borders
Diffstat (limited to 'point.c')
-rw-r--r--point.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/point.c b/point.c
index 27d62be..aef23ef 100644
--- a/point.c
+++ b/point.c
@@ -15,11 +15,15 @@ uint16_t index_to_offset(struct point *point) {
}
uint8_t element(struct point *point) {
- return point->page->elements[index_to_offset(point)];
+ if (point->index == point->page->element_count) {
+ return point->page->next->elements[0];
+ } else {
+ return point->page->elements[index_to_offset(point)];
+ }
}
bool at_eof(struct point *point) {
- return point->index == point->page->element_count;
+ return point->index == point->page->element_count && !point->page->next;
}
void move_point_forward(struct point *point) {