From df7d7732c61deec0102950cb3d79b9bd114e73a9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Jul 2009 14:32:29 +0200 Subject: 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). --- src/state_file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3