Function sbrk [src]
Prototype
pub fn sbrk(n: usize) usize
Parameters
n: usize
Source
pub fn sbrk(n: usize) usize {
if (bloc == 0) {
// we are at the start
bloc = @intFromPtr(&ExecData.end);
bloc_max = @intFromPtr(&ExecData.end);
}
const bl = std.mem.alignForward(usize, bloc, std.heap.pageSize());
const n_aligned = std.mem.alignForward(usize, n, std.heap.pageSize());
if (bl + n_aligned > bloc_max) {
// we need to allocate
if (brk_(bl + n_aligned) < 0) return 0;
bloc_max = bl + n_aligned;
}
bloc = bloc + n_aligned;
return bl;
}