mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 19:09:32 +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);
|
return shrink(allocator, old_mem, old_align, new_size, new_align);
|
||||||
}
|
}
|
||||||
const result = try alloc(allocator, new_size, new_align);
|
const result = try alloc(allocator, new_size, new_align);
|
||||||
|
if (old_mem.len != 0) {
|
||||||
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
|
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
|
||||||
if (old_mem.len > 0) {
|
|
||||||
_ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len);
|
_ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user