This commit is contained in:
Nils O. Selåsdal
2026-05-11 22:37:01 +02:00
commit c9a51a85ea
14 changed files with 809 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#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;
}