aboutsummaryrefslogtreecommitdiffstats
path: root/src/state_file.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-07-25 11:01:05 +0200
committerMax Kellermann <max@duempel.org>2010-07-25 12:01:59 +0200
commit838790fc2d12bb763341cebe7700bd21231e2105 (patch)
tree653ea0164f394eaa7ceab51448b5725fca46d664 /src/state_file.c
parent1ff2d5b689a66671c9dc62f297d69f00cbea9a6e (diff)
downloadmpd-838790fc2d12bb763341cebe7700bd21231e2105.tar.gz
mpd-838790fc2d12bb763341cebe7700bd21231e2105.tar.xz
mpd-838790fc2d12bb763341cebe7700bd21231e2105.zip
state_file: use the text_file library
Don't use a large stack buffer.
Diffstat (limited to '')
-rw-r--r--src/state_file.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/state_file.c b/src/state_file.c
index e048de7a0..55af25d5c 100644
--- a/src/state_file.c
+++ b/src/state_file.c
@@ -23,6 +23,7 @@
#include "playlist.h"
#include "playlist_state.h"
#include "volume.h"
+#include "text_file.h"
#include "glib_compat.h"
#include <glib.h>
@@ -76,7 +77,6 @@ static void
state_file_read(void)
{
FILE *fp;
- char line[1024];
bool success;
assert(state_file_path != NULL);
@@ -90,12 +90,12 @@ state_file_read(void)
return;
}
- while (fgets(line, sizeof(line), fp) != NULL) {
- g_strchomp(line);
-
+ GString *buffer = g_string_sized_new(1024);
+ const char *line;
+ while ((line = read_text_line(fp, buffer)) != NULL) {
success = read_sw_volume_state(line) ||
audio_output_state_read(line) ||
- playlist_state_restore(line, fp, &g_playlist);
+ playlist_state_restore(line, fp, buffer, &g_playlist);
if (!success)
g_warning("Unrecognized line in state file: %s", line);
}
@@ -105,6 +105,9 @@ state_file_read(void)
prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version();
prev_playlist_version = playlist_state_get_hash(&g_playlist);
+
+
+ g_string_free(buffer, true);
}
/**