Fixed a bad reference
This commit is contained in:
parent
0545282292
commit
a2a70a0f33
6 changed files with 43 additions and 12 deletions
|
|
@ -1,14 +1,13 @@
|
|||
package adb_pool
|
||||
|
||||
Pool :: struct($T: typeid) {
|
||||
pool: []T,
|
||||
usage, capacity: int,
|
||||
pool: []T,
|
||||
usage: int,
|
||||
}
|
||||
|
||||
init :: proc(pool: ^Pool($T), capacity: int, allocator := context.allocator) {
|
||||
pool.pool = make([]T, capacity, allocator)
|
||||
pool.usage = 0
|
||||
pool.capacity = capacity
|
||||
}
|
||||
|
||||
elems_available :: proc(pool: ^Pool($T), capacity: int) -> bool {
|
||||
|
|
@ -16,7 +15,9 @@ elems_available :: proc(pool: ^Pool($T), capacity: int) -> bool {
|
|||
}
|
||||
|
||||
get :: proc(pool: ^Pool($T), count: int) -> []T {
|
||||
elements := pool.pool[pool.usage:pool.usage + count]
|
||||
range_to := pool.usage + count
|
||||
assert(range_to <= len(pool.pool), "pool.get count reaches outside preallocated size")
|
||||
elements := pool.pool[pool.usage:]
|
||||
pool.usage += count
|
||||
return elements
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue