Browse Source

Make `map_alloc_dynamic` handle the `nil_allocator()`

gingerBill 2 years ago
parent
commit
5c106abe3f
1 changed files with 4 additions and 0 deletions
  1. 4 0
      core/runtime/dynamic_map_internal.odin

+ 4 - 0
core/runtime/dynamic_map_internal.odin

@@ -334,6 +334,10 @@ map_alloc_dynamic :: proc "odin" (info: ^Map_Info, log2_capacity: uintptr, alloc
 
 
 	data := mem_alloc_non_zeroed(int(size), MAP_CACHE_LINE_SIZE, allocator, loc) or_return
 	data := mem_alloc_non_zeroed(int(size), MAP_CACHE_LINE_SIZE, allocator, loc) or_return
 	data_ptr := uintptr(raw_data(data))
 	data_ptr := uintptr(raw_data(data))
+	if data_ptr == 0 {
+		err = .Out_Of_Memory
+		return
+	}
 	if intrinsics.expect(data_ptr & CACHE_MASK != 0, false) {
 	if intrinsics.expect(data_ptr & CACHE_MASK != 0, false) {
 		panic("allocation not aligned to a cache line", loc)
 		panic("allocation not aligned to a cache line", loc)
 	} else {
 	} else {