Files
lilalloc/test/lpool_test.c
T
Nils O. Selåsdal c9a51a85ea Initial
2026-05-11 22:37:01 +02:00

33 lines
839 B
C

#include <stdio.h>
#include "lpool.h"
struct TestData {
float x[3];
float y[3];
float z[3];
float w[3];
};
int main(int argc, char *argv[])
{
_Alignas(16) uint8_t store[2048];
LPool pool;
lpool_init(&pool, store, sizeof store, sizeof(struct TestData), _Alignof(struct TestData));
printf("align=%u capacity=%u block_size=%u\n", pool.align, pool.capacity, pool.block_size);
struct TestData *data = lpool_alloc(&pool);
size_t allocs = 1;
for (;;) {
struct TestData *t = lpool_alloc(&pool);
if (t == NULL) {
break;
}
allocs++;
}
printf("Total allocs = %zu\n", allocs);
printf("alloc succeded = %d\n", lpool_alloc(&pool) != NULL);
lpool_free(&pool, data);
printf("alloc succeded = %d\n", lpool_alloc(&pool) != NULL);
return 0;
}