reduce size allocated for blocks

This commit is contained in:
biglyderv 2025-03-31 21:38:33 -04:00
parent d356b5423e
commit e6c412e661
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5

View file

@ -15,16 +15,21 @@ int load_elements(hashmap *m, char *table, int use_inv) {
return 0; return 0;
char *str; char *str;
char *str2;
int did_something = 0; int did_something = 0;
while (1) { while (1) {
str = calloc(MAX_FILE_SIZE, sizeof(char)); str2 = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str, MAX_FILE_SIZE, fptr)) { if (!fgets(str2, MAX_FILE_SIZE, fptr)) {
free(str); free(str2);
break; break;
} }
str = calloc(strlen(str2) + 1, sizeof(char));
strcpy(str, str2);
free(str2);
did_something = 1; did_something = 1;
if (use_inv == 1) { if (use_inv == 1) {