garbage collection

This commit is contained in:
biglyderv 2025-03-26 01:20:38 -04:00
parent c02e8aa59a
commit e6165f3af8
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
6 changed files with 44 additions and 21 deletions

View file

@ -20,13 +20,15 @@ int load_elements(hashmap *m, char *table, int use_inv) {
while (1) {
str = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str, MAX_FILE_SIZE, fptr))
if (!fgets(str, MAX_FILE_SIZE, fptr)) {
free(str);
break;
}
did_something = 1;
if (use_inv) {
hashmap_set(m, str, strlen(str) - 1, (uintptr_t)1);
hashmap_set(m, str, strlen(str) - 1, (uintptr_t)1, 0);
continue;
}
@ -34,7 +36,7 @@ int load_elements(hashmap *m, char *table, int use_inv) {
combo[0] = '\0';
combo++;
hashmap_set(m, combo, strlen(combo) - 1, (uintptr_t)str);
hashmap_set(m, combo, strlen(combo) - 1, (uintptr_t)str, 1);
}
if (!did_something) {