garbage collection
This commit is contained in:
parent
c02e8aa59a
commit
e6165f3af8
6 changed files with 44 additions and 21 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue