Explorar o código

Add assert into scratch_allocator_proc to prevent initialization cycles #504

gingerBill %!s(int64=5) %!d(string=hai) anos
pai
achega
89ccb5b99f
Modificáronse 2 ficheiros con 2 adicións e 1 borrados
  1. 2 0
      core/mem/allocators.odin
  2. 0 1
      examples/demo/demo.odin

+ 2 - 0
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));
 	}
 

+ 0 - 1
examples/demo/demo.odin

@@ -1836,4 +1836,3 @@ main :: proc() {
 		soa_struct_layout();
 	}
 }
-