aboutsummaryrefslogtreecommitdiff
path: root/lib/alloc/arena_free.c
blob: dc2b45e7df297ab514c52bf68e904a2ac2e4b66c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <sys/mman.h>

#include <stdlib.h>

#include "alloc.h"
#include "macros.h"

void
arena_free(arena *a)
{
	ASSUME(a != nullptr);

	struct _region *cur, *next;
	for (cur = a->_head; cur != nullptr; cur = next) {
		next = cur->next;
		munmap(cur->data, cur->cap);
		free(cur);
	}
	a->_head = nullptr;
}