aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-12-15 11:19:13 +0000
committergingerBill <bill@gingerbill.org>2019-12-15 11:20:06 +0000
commit89ccb5b99f39cdb673435e37cea1f3db8a7224a6 (patch)
tree46fad3c673012cc42cd5bcffde2bff64a34df79d
parent7f5021c8e95e2861388c89d9d467d773339d5f4a (diff)
Add assert into scratch_allocator_proc to prevent initialization cycles #504
-rw-r--r--core/mem/allocators.odin2
-rw-r--r--examples/demo/demo.odin1
2 files changed, 2 insertions, 1 deletions
diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin
index 7ef094bc1..cc21b84ef 100644
--- a/core/mem/allocators.odin
+++ b/core/mem/allocators.odin
@@ -116,6 +116,8 @@ scratch_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
if scratch.data == nil {
DEFAULT_SCRATCH_BACKING_SIZE :: 1<<22;
+ assert(context.allocator.procedure != scratch_allocator_proc &&
+ context.allocator.data != allocator_data);
scratch_allocator_init(scratch, make([]byte, 1<<22));
}
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 1fce88ce9..af9e606cb 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -1836,4 +1836,3 @@ main :: proc() {
soa_struct_layout();
}
}
-