From 3a4f0d85a615111f3ceabd6e17b820337bf4198f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 1 Oct 2020 17:04:56 +0100 Subject: [PATCH] Fix container.Array and container.Ring --- core/container/array.odin | 7 +++++-- core/container/ring.odin | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/container/array.odin b/core/container/array.odin index b422a2cf9..1f2cdc58c 100644 --- a/core/container/array.odin +++ b/core/container/array.odin @@ -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; diff --git a/core/container/ring.odin b/core/container/ring.odin index 86e04fb50..d0e7d9b52 100644 --- a/core/container/ring.odin +++ b/core/container/ring.odin @@ -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; } }