aboutsummaryrefslogtreecommitdiff
path: root/core/container/small_array
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2024-09-24 02:32:06 -0700
committerColin Davidson <colrdavidson@gmail.com>2024-09-24 02:32:06 -0700
commitf3ab14b8ccb45d0fef8a96937635bdf0943ce7d6 (patch)
tree1309d7c797117463996a84522ef3d1c9713a286c /core/container/small_array
parent99938c7d4fb26d43a07dd4b8f4f00ab87e67e73f (diff)
parentf7d74ff3a8596efef67d151ffb758ed085e94be0 (diff)
Merge branch 'master' into macharena
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 {