diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-05-25 01:02:43 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2020-05-26 02:20:16 -0400 |
commit | 6eb63be564e5d99e9ead3c10e98ab684363428f2 (patch) | |
tree | 11b89d0a3d86526efeed924cc028ec73de89004e | |
parent | 56f138f1de82d4bf7e21282f115fbcb63a6fe4d4 (diff) |
Fix double ended queue size.
-rw-r--r-- | collections/double_ended_queue.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 88d4641..a49b018 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -9,7 +9,7 @@ struct double_ended_queue { void **base, **end, **beg; - int i, limit; + int limit; }; deq* deq_new() @@ -47,7 +47,12 @@ deq *root; if (!root) { return -1; } - return (root->end - root->beg); + + if (root->beg <= root->end) { + return (root->end - root->beg); + } + + return (root->base + root->limit - root->beg) + (root->end - root->base); } void deq_resize(root) |