From 25fe79b937f82140a394c1179083216798b6364d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 17 Mar 2017 23:18:56 +0100 Subject: [PATCH] mpdclient: move code to mpdclient_status_free() --- src/mpdclient.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mpdclient.c b/src/mpdclient.c index 2ae91b4..e1aee1c 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -118,6 +118,16 @@ mpdclient_free(struct mpdclient *c) g_free(c); } +static void +mpdclient_status_free(struct mpdclient *c) +{ + if (c->status == NULL) + return; + + mpd_status_free(c->status); + c->status = NULL; +} + void mpdclient_disconnect(struct mpdclient *c) { @@ -133,9 +143,7 @@ mpdclient_disconnect(struct mpdclient *c) } c->connection = NULL; - if (c->status) - mpd_status_free(c->status); - c->status = NULL; + mpdclient_status_free(c); playlist_clear(&c->playlist); @@ -194,8 +202,7 @@ mpdclient_update(struct mpdclient *c) return false; /* free the old status */ - if (c->status) - mpd_status_free(c->status); + mpdclient_status_free(c); /* retrieve new status */ c->status = mpd_run_status(connection); -- 2.30.2