add assignment operator and unify memory pools

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.
This commit is contained in:
r4
2021-12-21 11:40:49 +01:00
parent 21694f98ac
commit 63af3e907b
11 changed files with 121 additions and 48 deletions

18
pool_test.c Normal file
View File

@@ -0,0 +1,18 @@
#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);
}