Changeset 1e52e1f


Ignore:
Timestamp:
2010-07-11T10:30:27Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
af9f2ca
Parents:
e92c4f4
Message:

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.)

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ipc.c

    re92c4f4 r1e52e1f  
    324324                                   "Would you like to take over this session?",
    325325                                   ipc_child_cmd_takeover_yes,
    326                                    ipc_child_cmd_takeover_no, irc );
     326                                   ipc_child_cmd_takeover_no, NULL, irc );
    327327               
    328328                /* This one's going to connect to accounts, avoid that. */
  • protocols/nogaim.c

    re92c4f4 r1e52e1f  
    380380               query_callback doit, query_callback dont )
    381381{
    382         query_add( (irc_t *) ic->bee->ui_data, ic, msg, doit, dont, data );
     382        query_add( (irc_t *) ic->bee->ui_data, ic, msg, doit, dont, g_free, data );
    383383}
    384384
     
    478478        data->handle = g_strdup( handle );
    479479        query_add( (irc_t *) ic->bee->ui_data, ic, s,
    480                    imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
     480                   imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, g_free, data );
    481481}
    482482
     
    511511        data->handle = g_strdup( handle );
    512512        query_add( (irc_t *) ic->bee->ui_data, ic, s,
    513                    imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
     513                   imcb_ask_add_cb_yes, imcb_ask_add_cb_no, g_free, data );
    514514}
    515515
  • protocols/purple/purple.c

    re92c4f4 r1e52e1f  
    877877        q = g_strdup_printf( "Request: %s\n\n%s\n\n%s", title, primary, secondary );
    878878        pqad->bee_data = query_add( local_bee->ui_data, purple_ic_by_pa( account ), q,
    879                 prplcb_request_action_yes, prplcb_request_action_no, pqad );
     879                prplcb_request_action_yes, prplcb_request_action_no, g_free, pqad );
    880880       
    881881        g_free( q );
  • query.c

    re92c4f4 r1e52e1f  
    3131
    3232query_t *query_add( irc_t *irc, struct im_connection *ic, char *question,
    33                     query_callback yes, query_callback no, void *data )
     33                    query_callback yes, query_callback no, query_callback free,
     34                    void *data )
    3435{
    3536        query_t *q = g_new0( query_t, 1 );
     
    3940        q->yes = yes;
    4041        q->no = no;
     42        q->free = free;
    4143        q->data = data;
    4244       
     
    9496       
    9597        g_free( q->question );
    96         if( q->data ) g_free( q->data ); /* Memory leak... */
     98        if( q->free && q->data )
     99                q->free( q->data );
    97100        g_free( q );
    98101}
  • query.h

    re92c4f4 r1e52e1f  
    3333        struct im_connection *ic;
    3434        char *question;
    35         query_callback yes, no;
     35        query_callback yes, no, free;
    3636        void *data;
    3737        struct query *next;
     
    3939
    4040query_t *query_add( irc_t *irc, struct im_connection *ic, char *question,
    41                     query_callback yes, query_callback no, void *data );
     41                    query_callback yes, query_callback no, query_callback free,
     42                    void *data );
    4243void query_del( irc_t *irc, query_t *q );
    4344void query_del_by_conn( irc_t *irc, struct im_connection *ic );
Note: See TracChangeset for help on using the changeset viewer.