container/queue: Let queues be re-initialized with different allocators

This commit is contained in:
Feoramund
2025-06-11 08:15:50 -04:00
parent 81f5763482
commit 040d79e1b9
+6 -3
View File
@@ -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)
}