From 36813a2128948f7f24128213733e03e7172b93f2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 16 Dec 2014 09:16:09 +0100 Subject: libmount: monitor unref function refactoring Signed-off-by: Karel Zak --- libmount/src/monitor.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'libmount/src/monitor.c') diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 739bd1afc..6d6b2056a 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -87,16 +87,6 @@ static void free_monitor_entry(struct monitor_entry *me) free(me); } -static void free_monitor(struct libmnt_monitor *mn) -{ - - while (!list_empty(&mn->ents)) { - struct monitor_entry *me = list_entry(mn->ents.next, - struct monitor_entry, ents); - free_monitor_entry(me); - } -} - /** * mnt_unref_monitor: * @mn: monitor pointer @@ -106,10 +96,16 @@ static void free_monitor(struct libmnt_monitor *mn) */ void mnt_unref_monitor(struct libmnt_monitor *mn) { - if (mn) { - mn->refcount--; - if (mn->refcount <= 0) - free_monitor(mn); + if (!mn) + return; + + mn->refcount--; + if (mn->refcount <= 0) { + while (!list_empty(&mn->ents)) { + struct monitor_entry *me = list_entry(mn->ents.next, + struct monitor_entry, ents); + free_monitor_entry(me); + } } } -- cgit v1.2.3-55-g7522