浏览代码

Make `map_alloc_dynamic` handle the `nil_allocator()`

gingerBill 2 年之前
父节点
当前提交
5c106abe3f
共有 1 个文件被更改,包括 4 次插入0 次删除
  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_ptr := uintptr(raw_data(data))
+	if data_ptr == 0 {
+		err = .Out_Of_Memory
+		return
+	}
 	if intrinsics.expect(data_ptr & CACHE_MASK != 0, false) {
 		panic("allocation not aligned to a cache line", loc)
 	} else {