summaryrefslogtreecommitdiffstats
path: root/src/socket-proxy/socket-proxyd.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 12:35:49 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 21:30:30 +0100
commit224b0e7ad0116579f830b7dd387b97c3facb65d9 (patch)
treed769049843011ec955d86af31e2f0d62c4521f38 /src/socket-proxy/socket-proxyd.c
parentUse hashmap_free_free where appropriate (diff)
downloadsystemd-224b0e7ad0116579f830b7dd387b97c3facb65d9.tar.xz
systemd-224b0e7ad0116579f830b7dd387b97c3facb65d9.zip
Add set/hashmap helpers for non-trivial freeing and use where straighforward
A macro is needed because otherwise we couldn't ensure type safety. Some simple tests are included. No functional change intended.
Diffstat (limited to 'src/socket-proxy/socket-proxyd.c')
-rw-r--r--src/socket-proxy/socket-proxyd.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 8887e2f989..d4f401d996 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -92,19 +92,10 @@ static void connection_free(Connection *c) {
}
static void context_free(Context *context) {
- sd_event_source *es;
- Connection *c;
-
assert(context);
- while ((es = set_steal_first(context->listen)))
- sd_event_source_unref(es);
-
- while ((c = set_first(context->connections)))
- connection_free(c);
-
- set_free(context->listen);
- set_free(context->connections);
+ set_free_with_destructor(context->listen, sd_event_source_unref);
+ set_free_with_destructor(context->connections, connection_free);
sd_event_unref(context->event);
sd_resolve_unref(context->resolve);