Fix container.Array and container.Ring

This commit is contained in:
gingerBill
2020-10-01 17:04:56 +01:00
parent c604e359c7
commit 3a4f0d85a6
2 changed files with 6 additions and 3 deletions

View File

@@ -10,6 +10,8 @@ Array :: struct(T: typeid) {
allocator: mem.Allocator,
}
ARRAY_DEFAULT_CAPACITY :: 16;
/*
array_init :: proc {
array_init_none,
@@ -42,11 +44,12 @@ array_set_capacity
array_grow
*/
array_init_none :: proc(a: ^$A/Array, allocator := context.allocator) {
array_init_len(a, 0, allocator);
array_init_len_cap(a, 0, ARRAY_DEFAULT_CAPACITY, allocator);
}
array_init_len :: proc(a: ^$A/Array, len: int, allocator := context.allocator) {
array_init_len_cap(a, 0, 16, allocator);
array_init_len_cap(a, len, len, allocator);
}
array_init_len_cap :: proc(a: ^$A/Array($T), len: int, cap: int, allocator := context.allocator) {
a.allocator = allocator;

View File

@@ -64,7 +64,7 @@ ring_len :: proc(r: ^$R/Ring) -> int {
n := 0;
if r != nil {
n = 1;
for p := ring_next(p); p != r; p = p.next {
for p := ring_next(&p); p != r; p = p.next {
n += 1;
}
}