<sbrk.h>¶
Program break for the heap allocator.
#include <sbrk.h>
Structures¶
Arena¶
An arena: a buffer and how much of it is used. The heap's reservation and current break.
| Field | Type | Description |
|---|---|---|
base |
uint8_t * |
Start of the buffer. |
size |
size_t |
Buffer size in bytes. |
offset |
size_t |
Bytes handed out so far. |
base |
VirtAddr |
Start of the reservation. |
brk |
VirtAddr |
Current break. |
mapped |
VirtAddr |
End of the reservation. |
Functions¶
sbrk¶
void * sbrk(intptr_t incr);
Moves the program break by incr bytes.
The first call reserves 32 MiB of anonymous memory, filled on demand; the break moves within that reservation only.
| Parameter | Direction | Description |
|---|---|---|
incr |
in | Bytes to grow by, or a negative number to shrink by. |
Returns: The previous break, or (void *)-1 if the reservation cannot be made or the break would leave it.