63af3e907b
The unification of memory pools also fixed some memory leaks and hopefully reduced the mallocs of identifier strings significantly by giving them the same pool as the token stream.
19 lines
461 B
C
19 lines
461 B
C
#include "util.c"
|
|
|
|
typedef struct Test {
|
|
char a_string[64];
|
|
} Test;
|
|
|
|
int main(void) {
|
|
Pool *p = pool_new(1);
|
|
Test *t = pool_alloc(p, sizeof(Test));
|
|
strcpy(t->a_string, "a test string");
|
|
Test *tarr = pool_alloc(p, sizeof(Test) * 32);
|
|
strcpy(tarr[31].a_string, "another test string");
|
|
char *c = pool_alloc(p, 1);
|
|
*c = 'a';
|
|
Test *largearr = pool_alloc(p, sizeof(Test) * 1024);
|
|
strcpy(largearr[1023].a_string, "yet another test string");
|
|
pool_term(p);
|
|
}
|