Changeset 9da0bbf for protocols/jabber


Ignore:
Timestamp:
2007-07-02T22:12:03Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e900442
Parents:
5d7dc00
Message:

Added (and using) jabber_chat_free() for better memory management, fixed
channel name generation code in root_commands.c and fixed one memory leak
in jabber_buddy_remove_bare().

Location:
protocols/jabber
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    r5d7dc00 r9da0bbf  
    6363       
    6464        return c;
     65}
     66
     67void jabber_chat_free( struct groupchat *c )
     68{
     69        struct jabber_chat *jc = c->data;
     70       
     71        jabber_buddy_remove_bare( c->ic, jc->name );
     72       
     73        g_free( jc->my_full_jid );
     74        g_free( jc->name );
     75        g_free( jc );
     76       
     77        imcb_chat_free( c );
    6578}
    6679
     
    192205               
    193206                if( bud == jc->me )
    194                 {
    195                         jabber_buddy_remove_bare( ic, jc->name );
    196                        
    197                         g_free( jc->name );
    198                         g_free( jc );
    199                         imcb_chat_free( chat );
    200                 }
     207                        jabber_chat_free( chat );
    201208        }
    202209}
  • protocols/jabber/jabber.c

    r5d7dc00 r9da0bbf  
    198198       
    199199        while( ic->groupchats )
    200                 imcb_chat_free( ic->groupchats );
     200                jabber_chat_free( ic->groupchats );
    201201       
    202202        if( jd->r_inpa >= 0 )
  • protocols/jabber/jabber.h

    r5d7dc00 r9da0bbf  
    220220/* conference.c */
    221221struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password );
     222void jabber_chat_free( struct groupchat *c );
    222223int jabber_chat_msg( struct groupchat *ic, char *message, int flags );
    223224int jabber_chat_leave( struct groupchat *c, const char *reason );
  • protocols/jabber/jabber_util.c

    r5d7dc00 r9da0bbf  
    542542   specified bare JID. Use this when removing someone from the contact
    543543   list, for example. */
    544 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ )
     544int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid )
    545545{
    546546        struct jabber_data *jd = ic->proto_data;
    547547        struct jabber_buddy *bud, *next;
    548         char *bare_jid;
    549        
    550         if( strchr( bare_jid_, '/' ) )
     548       
     549        if( strchr( bare_jid, '/' ) )
    551550                return 0;
    552551       
    553         bare_jid = jabber_normalize( bare_jid_ );
    554        
    555         if( ( bud = g_hash_table_lookup( jd->buddies, bare_jid ) ) )
     552        if( ( bud = jabber_buddy_by_jid( ic, bare_jid, GET_BUDDY_FIRST ) ) )
    556553        {
    557554                /* Most important: Remove the hash reference. We don't know
    558555                   this buddy anymore. */
    559556                g_hash_table_remove( jd->buddies, bud->bare_jid );
     557                g_free( bud->bare_jid );
    560558               
    561559                /* Deallocate the linked list of resources. */
    562560                while( bud )
    563561                {
     562                        /* ext_jid && anonymous means that this buddy is
     563                           specific to one groupchat (the one we're
     564                           currently cleaning up) so it can be deleted
     565                           completely. */
     566                        if( bud->ext_jid && bud->flags & JBFLAG_IS_ANONYMOUS )
     567                                imcb_remove_buddy( ic, bud->ext_jid, NULL );
     568                       
    564569                        next = bud->next;
    565570                        g_free( bud->ext_jid );
     
    570575                }
    571576               
    572                 g_free( bare_jid );
    573577                return 1;
    574578        }
    575579        else
    576580        {
    577                 g_free( bare_jid );
    578581                return 0;
    579582        }
Note: See TracChangeset for help on using the changeset viewer.