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