diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-11 08:15:50 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-11 11:55:30 -0400 |
| commit | 040d79e1b99d952907167b9688b776920ad1d300 (patch) | |
| tree | cb6faa971f8353a6fee2ffebe239e9b9058f4533 /core/container/queue | |
| parent | 81f57634820279443abb7cc4fd3465477201e167 (diff) | |
container/queue: Let queues be re-initialized with different allocators
Diffstat (limited to 'core/container/queue')
| -rw-r--r-- | core/container/queue/queue.odin | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin index 75b00d376..7e3e18075 100644 --- a/core/container/queue/queue.odin +++ b/core/container/queue/queue.odin @@ -23,10 +23,13 @@ DEFAULT_CAPACITY :: 16 Initialize a `Queue` with a starting `capacity` and an `allocator`. */ init :: proc(q: ^$Q/Queue($T), capacity := DEFAULT_CAPACITY, allocator := context.allocator) -> runtime.Allocator_Error { - if q.data.allocator.procedure == nil { - q.data.allocator = allocator - } clear(q) + q.data = transmute([dynamic]T)runtime.Raw_Dynamic_Array{ + data = nil, + len = 0, + cap = 0, + allocator = allocator, + } return reserve(q, capacity) } |