aboutsummaryrefslogtreecommitdiff
path: root/core/container/queue/queue.odin
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-07-14 16:00:55 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-07-14 16:00:55 +0200
commitd90d7ed00280d997f6022420a5185a395d719b4d (patch)
tree53c9fbd92495edadb84bf6ceefb2ac37c7bb6c7e /core/container/queue/queue.odin
parent8319917898013e00423f9ac3dad5d2f33bee5fbc (diff)
Fix off-by-one in queue `back` and `back_ptr` procs
Diffstat (limited to 'core/container/queue/queue.odin')
-rw-r--r--core/container/queue/queue.odin4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin
index e7a60dde0..f83a5f2b7 100644
--- a/core/container/queue/queue.odin
+++ b/core/container/queue/queue.odin
@@ -95,11 +95,11 @@ front_ptr :: proc(q: ^$Q/Queue($T)) -> ^T {
}
back :: proc(q: ^$Q/Queue($T)) -> T {
- idx := (q.offset+uint(q.len))%builtin.len(q.data)
+ idx := (q.offset+uint(q.len - 1))%builtin.len(q.data)
return q.data[idx]
}
back_ptr :: proc(q: ^$Q/Queue($T)) -> ^T {
- idx := (q.offset+uint(q.len))%builtin.len(q.data)
+ idx := (q.offset+uint(q.len - 1))%builtin.len(q.data)
return &q.data[idx]
}