mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Dynamically adjust the size of line reads
* Dynamically adjust the size of line reads. * Remove some more uses of fgets with arbitrary sizes. * Fix reading of lines and width of n column. Fixes #514.
This commit is contained in:
11
Settings.c
11
Settings.c
@ -173,12 +173,15 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
||||
if (!fd)
|
||||
return false;
|
||||
|
||||
const int maxLine = 2048;
|
||||
char buffer[maxLine];
|
||||
bool readMeters = false;
|
||||
while (fgets(buffer, maxLine, fd)) {
|
||||
for (;;) {
|
||||
char* line = String_readLine(fd);
|
||||
if (!line) {
|
||||
break;
|
||||
}
|
||||
int nOptions;
|
||||
char** option = String_split(buffer, '=', &nOptions);
|
||||
char** option = String_split(line, '=', &nOptions);
|
||||
free (line);
|
||||
if (nOptions < 2) {
|
||||
String_freeArray(option);
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user