diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-14 16:00:55 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-14 16:00:55 +0200 |
| commit | d90d7ed00280d997f6022420a5185a395d719b4d (patch) | |
| tree | 53c9fbd92495edadb84bf6ceefb2ac37c7bb6c7e /core/container | |
| parent | 8319917898013e00423f9ac3dad5d2f33bee5fbc (diff) | |
Fix off-by-one in queue `back` and `back_ptr` procs
Diffstat (limited to 'core/container')
| -rw-r--r-- | core/container/queue/queue.odin | 4 |
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] } |