diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-05-27 03:39:03 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-05-27 03:39:03 -0400 |
commit | df2e0f59747d55ffd6fd47468d098aab1e9abfbe (patch) | |
tree | 6161b63dc452baf3a37da5f82a74906c7a5fa9f3 | |
parent | 0b8aa4ce92c042eabb3ebed94674aa6dc099a23c (diff) |
Fix double ended queue pop back w/ wrap around.
-rw-r--r-- | collections/double_ended_queue.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 25167e3..31ede5f 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -159,7 +159,10 @@ deq *root; return NULL; } - return tmp = *(--root->end); + tmp = *(root->end--); + root->end = (root->base + (root->end - root->base) % root->limit); + + return tmp; } void deq_free(root) |