reduce size allocated for blocks
This commit is contained in:
parent
d356b5423e
commit
e6c412e661
1 changed files with 10 additions and 5 deletions
15
src/loader.c
15
src/loader.c
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue