aboutsummaryrefslogtreecommitdiff
path: root/core/container/small_array
diff options
context:
space:
mode:
Diffstat (limited to 'core/container/small_array')
-rw-r--r--core/container/small_array/small_array.odin10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/container/small_array/small_array.odin b/core/container/small_array/small_array.odin
index b2068469d..77bb21cbc 100644
--- a/core/container/small_array/small_array.odin
+++ b/core/container/small_array/small_array.odin
@@ -139,9 +139,13 @@ clear :: proc "contextless" (a: ^$A/Small_Array($N, $T)) {
resize(a, 0)
}
-push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), items: ..T) {
- n := copy(a.data[a.len:], items[:])
- a.len += n
+push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), items: ..T) -> bool {
+ if a.len + builtin.len(items) <= cap(a^) {
+ n := copy(a.data[a.len:], items[:])
+ a.len += n
+ return true
+ }
+ return false
}
inject_at :: proc "contextless" (a: ^$A/Small_Array($N, $T), item: T, index: int) -> bool #no_bounds_check {