We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cfcabe1 commit 36ec42eCopy full SHA for 36ec42e
src/memory.zig
@@ -108,9 +108,12 @@ fn zmeshFree(maybe_ptr: ?*anyopaque) callconv(.c) void {
108
mem_mutex.lock();
109
defer mem_mutex.unlock();
110
111
- const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
112
- const mem = @as([*]align(mem_alignment.toByteUnits()) u8, @ptrCast(@alignCast(ptr)))[0..size];
113
- mem_allocator.?.free(mem);
+ const try_get_allocation = mem_allocations.?.fetchRemove(@intFromPtr(ptr));
+ if (try_get_allocation) |alloc| {
+ const size = alloc.value;
114
+ const mem = @as([*]align(mem_alignment.toByteUnits()) u8, @ptrCast(@alignCast(ptr)))[0..size];
115
+ mem_allocator.?.free(mem);
116
+ }
117
}
118
119
0 commit comments