diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-11 11:30:27 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-11 11:30:27 +0100 |
commit | 1e52e1ff518987092cfe94bc5c9c4479ed535019 (patch) | |
tree | 59a0f7c6725f37703797b8825058356ec6bf1f27 /query.c | |
parent | e92c4f4f63ca0ba9ac6f959f7ff894ad2fc72a04 (diff) |
When cleaning up queries, q->data is free()d. Even if it turns out to be
the "struct irc" containing all data belonging to a session. Sanitise
memory management a little bit here. (There are some memory leaks in here
too that need to be fixed at some point.)
Diffstat (limited to 'query.c')
-rw-r--r-- | query.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -30,7 +30,8 @@ static void query_display( irc_t *irc, query_t *q ); static query_t *query_default( irc_t *irc ); query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, - query_callback yes, query_callback no, void *data ) + query_callback yes, query_callback no, query_callback free, + void *data ) { query_t *q = g_new0( query_t, 1 ); @@ -38,6 +39,7 @@ query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, q->question = g_strdup( question ); q->yes = yes; q->no = no; + q->free = free; q->data = data; if( strchr( irc->umode, 'b' ) != NULL ) @@ -93,7 +95,8 @@ void query_del( irc_t *irc, query_t *q ) } g_free( q->question ); - if( q->data ) g_free( q->data ); /* Memory leak... */ + if( q->free && q->data ) + q->free( q->data ); g_free( q ); } |