check both main dir and parent dir (temp fix)

This commit is contained in:
biglyderv 2025-03-25 13:43:02 -04:00
parent f4be64fe19
commit 4bef1a220c
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
3 changed files with 29 additions and 10 deletions

View file

@ -6,21 +6,28 @@
#define MAX_FILE_SIZE 1024 * 16
void load_elements(hashmap *m, char *table, int use_inv) {
int load_elements(hashmap *m, char *table, int use_inv) {
FILE *fptr;
fptr = fopen(table, "r");
if (fptr == NULL)
return 0;
char *str;
int did_something = 0;
while (1) {
str = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str, MAX_FILE_SIZE, fptr))
break;
did_something = 1;
if (use_inv) {
hashmap_set(m, str, strlen(str) - 2, (uintptr_t)1);
continue;
hashmap_set(m, str, strlen(str) - 2, (uintptr_t)1);
continue;
}
char *combo = strstr(str, ";");
@ -30,5 +37,14 @@ void load_elements(hashmap *m, char *table, int use_inv) {
hashmap_set(m, combo, strlen(combo) - 1, (uintptr_t)str);
}
printf("%i\n",did_something);
if (!did_something) {
free(str);
}
return did_something;
// todo: properly free this
}