Introduce our own shutdown callback mechanism.
Instead of adding stuff to `_shutdown()`, we can now register a shutdown routine from the respective `init()` function of our modules. This also has the advantage, that we're sure they're called in reverse order from how the initialization happened. I didn't simply use `atexit()` because POSIX says that the number of possible callbacks is limited (min 32) and I was not sure whether we will maybe extend this number at one point. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -91,17 +91,8 @@ static Occupant* _muc_occupant_new(const char* const nick, const char* const jid
|
||||
muc_affiliation_t affiliation, resource_presence_t presence, const char* const status);
|
||||
static void _occupant_free(Occupant* occupant);
|
||||
|
||||
void
|
||||
muc_init(void)
|
||||
{
|
||||
invite_ac = autocomplete_new();
|
||||
confservers_ac = autocomplete_new();
|
||||
rooms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_free_room);
|
||||
invite_passwords = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||
}
|
||||
|
||||
void
|
||||
muc_close(void)
|
||||
static void
|
||||
_muc_close(void)
|
||||
{
|
||||
autocomplete_free(invite_ac);
|
||||
autocomplete_free(confservers_ac);
|
||||
@@ -113,6 +104,16 @@ muc_close(void)
|
||||
confservers_ac = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
muc_init(void)
|
||||
{
|
||||
prof_add_shutdown_routine(_muc_close);
|
||||
invite_ac = autocomplete_new();
|
||||
confservers_ac = autocomplete_new();
|
||||
rooms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_free_room);
|
||||
invite_passwords = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||
}
|
||||
|
||||
void
|
||||
muc_confserver_add(const char* const server)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user