X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tools%2Fdbus-cleanup-sockets.c;h=1b6709af54b615404600bd59fe76324d052907c1;hb=ef8d0d75d538db543ab0ff68809656f3972e3848;hp=f163848c7dc970f290fa1c052b2b510fd9ce356b;hpb=0e024fc53a5effadedd56427ffe261c417e45222;p=platform%2Fupstream%2Fdbus.git diff --git a/tools/dbus-cleanup-sockets.c b/tools/dbus-cleanup-sockets.c index f163848..1b6709a 100644 --- a/tools/dbus-cleanup-sockets.c +++ b/tools/dbus-cleanup-sockets.c @@ -1,4 +1,4 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-cleanup-sockets.c dbus-cleanup-sockets utility * * Copyright (C) 2003 Red Hat, Inc. @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include @@ -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 */ @@ -364,7 +381,7 @@ usage (int ecode) static void version (void) { - printf ("D-BUS Socket Cleanup Utility %s\n" + printf ("D-Bus Socket Cleanup Utility %s\n" "Copyright (C) 2003 Red Hat, Inc.\n" "Copyright (C) 2002 Michael Meeks\n" "This is free software; see the source for copying conditions.\n" @@ -376,14 +393,12 @@ version (void) int main (int argc, char **argv) { - const char *prev_arg; int i; int saw_doubledash; const char *dirname; saw_doubledash = FALSE; dirname = NULL; - prev_arg = NULL; i = 1; while (i < argc) { @@ -413,8 +428,6 @@ main (int argc, char **argv) dirname = arg; } - prev_arg = arg; - ++i; }