1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Call message_handlers_clear() upon disconnect

Free pubsub_event_handlers. Fix memory leaks.
This commit is contained in:
Michael Vetter 2019-06-19 23:49:04 +02:00
parent 11b8204d14
commit b8c8059402
3 changed files with 10 additions and 0 deletions

View File

@ -178,6 +178,14 @@ message_handlers_init(void)
pubsub_event_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
}
void
message_handlers_clear(void)
{
if (pubsub_event_handlers) {
g_hash_table_remove_all(pubsub_event_handlers);
}
}
void
message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata)
{

View File

@ -39,6 +39,7 @@ typedef int(*ProfMessageCallback)(xmpp_stanza_t *const stanza, void *const userd
typedef void(*ProfMessageFreeCallback)(void *userdata);
void message_handlers_init(void);
void message_handlers_clear(void);
void message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata);
#endif

View File

@ -216,6 +216,7 @@ session_disconnect(void)
iq_handlers_clear();
connection_disconnect();
message_handlers_clear();
connection_clear_data();
chat_sessions_clear();