mirror of
https://github.com/ziglang/zig.git
synced 2024-12-03 18:38:45 +00:00
DirectAllocator: move if > 0 condition above @memcpy
Minor improvement to 3c13aa17
as noted by daurnimator
This commit is contained in:
parent
3c13aa178b
commit
4b6f350369
@ -141,8 +141,8 @@ pub const DirectAllocator = struct {
|
||||
return shrink(allocator, old_mem, old_align, new_size, new_align);
|
||||
}
|
||||
const result = try alloc(allocator, new_size, new_align);
|
||||
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
|
||||
if (old_mem.len > 0) {
|
||||
if (old_mem.len != 0) {
|
||||
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
|
||||
_ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len);
|
||||
}
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user