|
|
@ -17,18 +17,22 @@ char *read_line(FILE *file) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (length == size) {
|
|
|
|
if (length == size) {
|
|
|
|
string = realloc(string, size *= 2);
|
|
|
|
char *new_string = realloc(string, size *= 2);
|
|
|
|
if (!string) {
|
|
|
|
if (!new_string) {
|
|
|
|
|
|
|
|
free(string);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string = new_string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string[length++] = c;
|
|
|
|
string[length++] = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (length + 1 == size) {
|
|
|
|
if (length + 1 == size) {
|
|
|
|
string = realloc(string, length + 1);
|
|
|
|
char *new_string = realloc(string, length + 1);
|
|
|
|
if (!string) {
|
|
|
|
if (!new_string) {
|
|
|
|
|
|
|
|
free(string);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string = new_string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string[length] = '\0';
|
|
|
|
string[length] = '\0';
|
|
|
|
return string;
|
|
|
|
return string;
|
|
|
|