Created
October 25, 2016 17:17
-
-
Save anonymous/ade9ed29fdcd9cbcb185a9303524c1a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/settings.c b/src/settings.c | |
index 115a71c..493e835 100644 | |
--- a/src/settings.c | |
+++ b/src/settings.c | |
@@ -201,9 +201,8 @@ void BarSettingsRead (BarSettings_t *settings) { | |
for (size_t j = 0; j < sizeof (configfiles) / sizeof (*configfiles); j++) { | |
static const char *formatMsgPrefix = "format_msg_"; | |
FILE *configfd; | |
- /* getline allocates these on the first run */ | |
- char *line = NULL; | |
- size_t lineLen = 0, lineNum = 0; | |
+ char line[1024]; | |
+ size_t lineNum = 0; | |
char * const path = BarGetXdgConfigDir (configfiles[j]); | |
assert (path != NULL); | |
@@ -214,8 +213,8 @@ void BarSettingsRead (BarSettings_t *settings) { | |
while (1) { | |
++lineNum; | |
- ssize_t ret = getline (&line, &lineLen, configfd); | |
- if (ret == -1) { | |
+ char * const ret = fgets (line, sizeof (line), configfd); | |
+ if (ret == NULL) { | |
/* EOF or error */ | |
break; | |
} | |
@@ -410,7 +409,6 @@ void BarSettingsRead (BarSettings_t *settings) { | |
fclose (configfd); | |
free (path); | |
- free (line); | |
} | |
/* check environment variable if proxy is not set explicitly */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment