Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."

This reverts commit 71bb8cd537.

This broke the CI on Windows.
This commit is contained in:
Andrew Kelley 2019-04-16 19:11:37 -04:00
parent b29241fc08
commit 4c03746926
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -118,14 +118,7 @@ pub const DirectAllocator = struct {
}
return old_mem[0..new_size];
},
Os.windows => {
if (new_size == 0) {
const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
_ = os.windows.HeapFree(self.heap_handle.?, 0, old_mem.ptr);
return old_mem[0..new_size];
}
return realloc(allocator, old_mem, old_align, new_size, new_align) catch {
Os.windows => return realloc(allocator, old_mem, old_align, new_size, new_align) catch {
const old_adjusted_addr = @ptrToInt(old_mem.ptr);
const old_record_addr = old_adjusted_addr + old_mem.len;
const root_addr = @intToPtr(*align(1) usize, old_record_addr).*;
@ -133,7 +126,6 @@ pub const DirectAllocator = struct {
const new_record_addr = old_record_addr - new_size + old_mem.len;
@intToPtr(*align(1) usize, new_record_addr).* = root_addr;
return old_mem[0..new_size];
};
},
else => @compileError("Unsupported OS"),
}
@ -151,7 +143,6 @@ pub const DirectAllocator = struct {
return result;
},
Os.windows => {
assert(new_size > 0);
if (old_mem.len == 0) return alloc(allocator, new_size, new_align);
const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);