Initial
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user