summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-17 12:18:40 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-17 12:18:40 +0000
commita8302efd2c4022eaa945b91c04a7f4601597bbe1 (patch)
tree32f0b86517aa1028b691f65b133548be98add30e
parent69c0c06e356f01bc34ddc42e2ee889fd9ea4a0ea (diff)
dbus-cleanup-sockets: free list of socket entries
Origin: vendor, Maemo Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33128 Bug-NB: NB#180486 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--tools/dbus-cleanup-sockets.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/dbus-cleanup-sockets.c b/tools/dbus-cleanup-sockets.c
index 487c4b07..1b6709af 100644
--- a/tools/dbus-cleanup-sockets.c
+++ b/tools/dbus-cleanup-sockets.c
@@ -138,16 +138,31 @@ socket_entry_new (const char *dir,
return se;
}
-#if 0
static void
free_socket_entry (SocketEntry *se)
{
- free (se->name);
- if (se->fd >= 0)
- close (se->fd);
- free (se);
+ if (se)
+ {
+ free (se->name);
+ if (se->fd >= 0)
+ close (se->fd);
+ free (se);
+ }
+}
+
+static void
+free_socket_entries (SocketEntry** entries,
+ int n_entries)
+{
+ int i;
+
+ if (entries)
+ {
+ for (i = 0; i < n_entries; ++i)
+ free_socket_entry (entries[i]);
+ free (entries);
+ }
}
-#endif
static void
read_sockets (const char *dir,
@@ -350,6 +365,8 @@ clean_dir (const char *dir)
}
unhandled_count += (n_entries - alive_count - cleaned_count);
+
+ free_socket_entries (entries, n_entries);
}
#endif /* AF_UNIX */