Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A arena might look like:
- struct Arena {
- void * ptr;
- size_t total_size;
- size_t filled_size;
- Arena *next;
- Arena *prev;
- }
- // malloc() would be implemented like:
- void* malloc (Arena *a, size_t s)
- {
- if (a->filled_size + s > a->total_size) { // arena is full
- // allocate new arena
- // insert it in the linked list
- // blah blah
- }
- void *result = a->ptr;
- a->ptr += s;
- a->filled_size += s;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement