Reserve a Region Before Allocating Blocks
sbrk-basics tracks raw bytes and growth attempts.
It does not yet align payloads, add headers, reuse blocks, or free them.
1 / 6
sbrk-basics tracks raw bytes and growth attempts.
It does not yet align payloads, add headers, reuse blocks, or free them.
Start 4096; request 24 successfully.
[4096,4120).The end pointer is outside the writable bytes.
Requests: 24 succeeds, 8 succeeds, 64 fails.
| Successful bytes | Growth attempts |
|---|---|
| 32 | 3 |
Zero and sbrk(0) queries do not count as growth attempts.
Reject before calling sbrk when:
INTPTR_MAX;SIZE_MAX - total_requested.Recognize (void *)-1 before updating successful bytes.
heap_init() resets accounting at the current boundary.
Freeing interior B cannot lower the break through later live C.
Raw one-byte requests do not imply aligned objects.
Start 1000; request 7 successfully, reject an unrepresentable increment, request 9 successfully.
Predict both pointers, break, byte total, and attempt count.
Then implement sbrk-basics and trace failure without exhausting real memory.