ArenaAllocatorReset
Description
Reset the arena cursor without freeing any chunks. All allocations made through arena become invalid, but the chunk list is kept so subsequent allocations are served without remapping.
Parameters
| Name | Direction | Description |
|---|---|---|
arena |
in,out | Arena allocator descriptor to reset. |
Success
Arena cursor is rewound to the start of the first chunk.
Failure
No action is taken when arena is not an arena allocator or has no live state.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Arena.c:259:
}
void ArenaAllocatorReset(Allocator *arena) {
ArenaState *state;
ArenaChunk *chunk; bool ok = (a != NULL) && (b != NULL);
ArenaAllocatorReset(&arena);
char *c = (char *)AllocatorAlloc(&arena, 4096, true);
ok = ok && (c != NULL) && (c == a); // Reset reuses the first chunk.
Last updated on