[mini] Provide a free function to the saved signal handler hash table.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Tue, 13 Sep 2016 11:18:10 +0000 (13:18 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Tue, 27 Sep 2016 10:35:14 +0000 (12:35 +0200)
This makes the cleanup code simpler, and also makes it easier to
replace saved signal handlers without having to worry about
leaking memory.

mono/mini/mini-posix.c

index 6f6e266a3b025d72fd9998435b46a8b053747b31..e192403487b04d4571351f9551a91bac3e4e065f 100644 (file)
@@ -167,21 +167,14 @@ save_old_signal_handler (int signo, struct sigaction *old_action)
        handler_to_save->sa_flags = old_action->sa_flags;
        
        if (!mono_saved_signal_handlers)
-               mono_saved_signal_handlers = g_hash_table_new (NULL, NULL);
+               mono_saved_signal_handlers = g_hash_table_new_full (NULL, NULL, NULL, g_free);
        g_hash_table_insert (mono_saved_signal_handlers, GINT_TO_POINTER (signo), handler_to_save);
 }
 
-static void
-free_saved_sig_handler_func (gpointer key, gpointer value, gpointer user_data)
-{
-       g_free (value);
-}
-
 static void
 free_saved_signal_handlers (void)
 {
        if (mono_saved_signal_handlers) {
-               g_hash_table_foreach (mono_saved_signal_handlers, free_saved_sig_handler_func, NULL);
                g_hash_table_destroy (mono_saved_signal_handlers);
                mono_saved_signal_handlers = NULL;
        }