01b8150625
remove the free function entirely. all allocators are now expected to implement reset instead. I reallized I never ever want to free an individual allocation ever again. The forever_allocator is a special case wherEreset is a no-op. The arena allocator was deleted. It will be replaced soon.
27 lines
779 B
C
27 lines
779 B
C
#include <criterion/criterion.h>
|
|
#include "cig.h"
|
|
|
|
#define EXPECT 5
|
|
Test(borrow_allocator, test) {
|
|
allocator_t balloc = borrow_allocator(&borrow_allocator_create());
|
|
int *ptr = allocator_alloc(balloc, sizeof(int));
|
|
*ptr = EXPECT;
|
|
cr_assert_eq(*ptr, EXPECT);
|
|
allocator_reset(balloc);
|
|
}
|
|
|
|
#define IS_SIZE 900
|
|
Test(borrow_allocator, with) {
|
|
with_borrow(foo) {
|
|
with_borrow(bar) {
|
|
}
|
|
int *is = allocator_alloc(foo, sizeof(int) * IS_SIZE);
|
|
for (int i = 0; i < IS_SIZE; i++) is[i] = i;
|
|
is = allocator_alloc(foo, sizeof(int) * IS_SIZE);
|
|
for (int i = 0; i < IS_SIZE; i++) is[i] = i;
|
|
is = allocator_alloc(foo, sizeof(int) * IS_SIZE);
|
|
for (int i = 0; i < IS_SIZE; i++) is[i] = i;
|
|
break;
|
|
}
|
|
}
|