diff options
author | Ben Pfaff <blp@nicira.com> | 2011-03-25 15:26:30 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-03-31 16:42:01 -0700 |
commit | b3c01ed3308e7899e98e981bf465f74be86f5f12 (patch) | |
tree | 20103c6515c654382cc9b43ae0058b7393a0defb /lib/fatal-signal.c | |
parent | f391294fde05ecae7c9a1ff8752f872a1db94f3a (diff) |
Convert shash users that don't use the 'data' value to sset instead.
In each of the cases converted here, an shash was used simply to maintain
a set of strings, with the shash_nodes' 'data' values set to NULL. This
commit converts them to use sset instead.
Diffstat (limited to 'lib/fatal-signal.c')
-rw-r--r-- | lib/fatal-signal.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index 81f8f284..ed82173a 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include <unistd.h> #include "poll-loop.h" #include "shash.h" +#include "sset.h" #include "socket-util.h" #include "util.h" #include "vlog.h" @@ -194,8 +195,8 @@ call_hooks(int sig_nr) } } -/* Files to delete on exit. (The 'data' member of each node is unused.) */ -static struct shash files = SHASH_INITIALIZER(&files); +/* Files to delete on exit. */ +static struct sset files = SSET_INITIALIZER(&files); /* Has a hook function been registered with fatal_signal_add_hook() (and not * cleared by fatal_signal_fork())? */ @@ -215,7 +216,7 @@ fatal_signal_add_file_to_unlink(const char *file) fatal_signal_add_hook(unlink_files, cancel_files, NULL, true); } - shash_add_once(&files, file, NULL); + sset_add(&files, file); } /* Unregisters 'file' from being unlinked when the program terminates via @@ -223,12 +224,7 @@ fatal_signal_add_file_to_unlink(const char *file) void fatal_signal_remove_file_to_unlink(const char *file) { - struct shash_node *node; - - node = shash_find(&files, file); - if (node) { - shash_delete(&files, node); - } + sset_find_and_delete(&files, file); } /* Like fatal_signal_remove_file_to_unlink(), but also unlinks 'file'. @@ -255,17 +251,17 @@ unlink_files(void *aux OVS_UNUSED) static void cancel_files(void *aux OVS_UNUSED) { - shash_clear(&files); + sset_clear(&files); added_hook = false; } static void do_unlink_files(void) { - struct shash_node *node; + const char *file; - SHASH_FOR_EACH (node, &files) { - unlink(node->name); + SSET_FOR_EACH (file, &files) { + unlink(file); } } |