aboutsummaryrefslogtreecommitdiffstats
path: root/src/state_file.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-15 14:32:29 +0200
committerMax Kellermann <max@duempel.org>2009-07-15 14:32:29 +0200
commitdf7d7732c61deec0102950cb3d79b9bd114e73a9 (patch)
treefeee15fb0d061ce3848430d2c9090b296bb45f24 /src/state_file.c
parent889b1c1eae6f6de14744371539d17bd85c87a70d (diff)
downloadmpd-df7d7732c61deec0102950cb3d79b9bd114e73a9.tar.gz
mpd-df7d7732c61deec0102950cb3d79b9bd114e73a9.tar.xz
mpd-df7d7732c61deec0102950cb3d79b9bd114e73a9.zip
state_file: simplified state_file_finish()
Return early from the destructor function when there is no configured state file. Don't check the timer, don't call g_free(NULL).
Diffstat (limited to '')
-rw-r--r--src/state_file.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/state_file.c b/src/state_file.c
index 073e85f6b..3791c057d 100644
--- a/src/state_file.c
+++ b/src/state_file.c
@@ -41,8 +41,7 @@ state_file_write(void)
{
FILE *fp;
- if (state_file_path == NULL)
- return;
+ assert(state_file_path != NULL);
g_debug("Saving state file %s", state_file_path);
@@ -114,11 +113,14 @@ state_file_init(const char *path)
void
state_file_finish(void)
{
+ if (state_file_path == NULL)
+ /* no state file configured, no cleanup required */
+ return;
+
if (save_state_source_id != 0)
g_source_remove(save_state_source_id);
- if (state_file_path != NULL)
- state_file_write();
+ state_file_write();
g_free(state_file_path);
}