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;
char *str;
char *str2;
int did_something = 0;
while (1) {
str = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str, MAX_FILE_SIZE, fptr)) {
free(str);
str2 = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str2, MAX_FILE_SIZE, fptr)) {
free(str2);
break;
}
str = calloc(strlen(str2) + 1, sizeof(char));
strcpy(str, str2);
free(str2);
did_something = 1;
if (use_inv == 1) {
@ -36,8 +41,8 @@ int load_elements(hashmap *m, char *table, int use_inv) {
combo_o[0] = '\0';
combo_o++;
char *combo = calloc(strlen(combo_o)+1,sizeof(char));
strcpy(combo,combo_o);
char *combo = calloc(strlen(combo_o) + 1, sizeof(char));
strcpy(combo, combo_o);
if (use_inv == 2) {
hashmap_set(m, str, strlen(str) - 1, (uintptr_t)combo, 1);