mono_assembly_close (mono_defaults.corlib->assembly);
mono_defaults.corlib = NULL;
+ mono_config_cleanup ();
mono_loader_cleanup ();
mono_classes_cleanup ();
mono_assemblies_cleanup ();
void
mono_monitor_cleanup (void)
{
+ MonitorArray *marray, *next = NULL;
+
/*DeleteCriticalSection (&monitor_mutex);*/
+
+ for (marray = monitor_allocated; marray; marray = next) {
+ next = marray->next;
+ g_free (marray);
+ }
}
/*
static GHashTable *config_handlers;
+static const char *mono_cfg_dir = NULL;
+static char *mono_cfg_dir_allocated = NULL;
+
/* when this interface is stable, export it. */
typedef struct MonoParseHandler MonoParseHandler;
g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler);
}
+void
+mono_config_cleanup (void)
+{
+ g_hash_table_destroy (config_handlers);
+ g_free (mono_cfg_dir_allocated);
+}
+
/* FIXME: error handling */
static void
#endif
}
-static const char *mono_cfg_dir = NULL;
-
/* Invoked during startup */
void
mono_set_config_dir (const char *dir)
/* If this variable is set, overrides the directory computed */
mono_cfg_dir = g_getenv ("MONO_CFG_DIR");
if (mono_cfg_dir == NULL)
- mono_cfg_dir = g_strdup (dir);
+ mono_cfg_dir = mono_cfg_dir_allocated = g_strdup (dir);
}
const char*
const char* mono_get_machine_config (void);
+void mono_config_cleanup (void);
void mono_config_parse (const char *filename);
void mono_config_for_assembly (MonoImage *assembly);
void mono_config_parse_memory (const char *buffer);
static MonoString*
mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig);
+static void
+free_main_args (void);
+
#define ldstr_lock() EnterCriticalSection (&ldstr_section)
#define ldstr_unlock() LeaveCriticalSection (&ldstr_section)
static CRITICAL_SECTION ldstr_section;
DeleteCriticalSection (&ldstr_section);
g_hash_table_destroy (type_initialization_hash);
g_hash_table_destroy (blocked_thread_hash);
+
+ free_main_args ();
}
/**
return res;
}
+static void
+free_main_args (void)
+{
+ int i;
+
+ for (i = 0; i < num_main_args; ++i)
+ g_free (main_args [i]);
+ g_free (main_args);
+}
+
/**
* mono_runtime_run_main:
* @method: the method to start the application with (usually Main)
mono_g_hash_table_foreach (threads, free_thread_static_data_helper, &data);
item->offset = offset;
item->size = size;
- item->next = thread_static_info.freelist;
- thread_static_info.freelist = item;
+
+ if (!mono_runtime_is_shutting_down ()) {
+ item->next = thread_static_info.freelist;
+ thread_static_info.freelist = item;
+ } else {
+ /* We could be called during shutdown after mono_thread_cleanup () is called */
+ g_free (item);
+ }
} else {
/* FIXME: free context static data as well */
}