diff options
Diffstat (limited to 'tools/dbus-cleanup-sockets.c')
-rw-r--r-- | tools/dbus-cleanup-sockets.c | 29 |
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 */ |