aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-29 19:55:55 +0100
committergingerBill <bill@gingerbill.org>2018-08-29 19:55:55 +0100
commit001837e6bb0448d439ce6208069265a1a7aefaf5 (patch)
tree7252984ec2c8d5844d8236006f9959b3dbee15da /examples
parent28523f17e2c702379dff89b024edcb1614256476 (diff)
Temporary allocator for `context`
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index f16571d56..ed26b9664 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -489,12 +489,15 @@ threading_example :: proc() {
when os.OS == "windows" {
fmt.println("# threading_example");
- unordered_remove :: proc(array: ^[dynamic]$T, index: int, loc := #caller_location) {
+ unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
runtime.bounds_check_error_loc(loc, index, len(array));
- array[index] = array[len(array)-1];
+ n := len(array)-1;
+ if index != n {
+ array[index] = array[n];
+ }
pop(array);
}
- ordered_remove :: proc(array: ^[dynamic]$T, index: int, loc := #caller_location) {
+ ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
runtime.bounds_check_error_loc(loc, index, len(array));
copy(array[index:], array[index+1:]);
pop(array);