Changeset e54112f for irc_channel.c
- Timestamp:
- 2010-05-02T23:44:33Z (14 years ago)
- Branches:
- master
- Children:
- 6a9d068
- Parents:
- bce78c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_channel.c
rbce78c8 re54112f 26 26 #include "bitlbee.h" 27 27 28 static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ); 28 29 static const struct irc_channel_funcs control_channel_funcs; 29 30 … … 71 72 72 73 irc->channels = g_slist_remove( irc->channels, ic ); 73 g_slist_free( ic->users ); 74 while( ic->users ) 75 { 76 g_free( ic->users->data ); 77 ic->users = g_slist_remove( ic->users, ic->users->data ); 78 } 74 79 75 80 g_free( ic->name ); … … 82 87 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ) 83 88 { 89 irc_channel_user_t *icu; 90 84 91 if( irc_channel_has_user( ic, iu ) ) 85 92 return 0; 86 93 87 ic->users = g_slist_insert_sorted( ic->users, iu, irc_user_cmp ); 94 icu = g_new0( irc_channel_user_t, 1 ); 95 icu->iu = iu; 96 97 ic->users = g_slist_insert_sorted( ic->users, icu, irc_channel_user_cmp ); 88 98 89 99 if( iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED ) … … 98 108 int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu ) 99 109 { 100 if( !irc_channel_has_user( ic, iu ) ) 110 irc_channel_user_t *icu; 111 112 if( !( icu = irc_channel_has_user( ic, iu ) ) ) 101 113 return 0; 102 114 103 ic->users = g_slist_remove( ic->users, iu ); 115 ic->users = g_slist_remove( ic->users, icu ); 116 g_free( icu ); 104 117 105 118 if( ic->flags & IRC_CHANNEL_JOINED ) … … 112 125 } 113 126 114 /* Currently a fairly stupid one-liner but I fear it's going to get worse. :-) */ 115 gboolean irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ) 116 { 117 return g_slist_find( ic->users, iu ) != NULL; 127 irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ) 128 { 129 GSList *l; 130 131 for( l = ic->users; l; l = l->next ) 132 { 133 irc_channel_user_t *icu = l->data; 134 135 if( icu->iu == iu ) 136 return icu; 137 } 138 139 return NULL; 118 140 } 119 141 … … 140 162 { 141 163 return strchr( CTYPES, name[0] ) != NULL && nick_ok( name + 1 ); 164 } 165 166 static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ) 167 { 168 const irc_channel_user_t *a = a_, *b = b_; 169 170 return irc_user_cmp( a->iu, b->iu ); 142 171 } 143 172
Note: See TracChangeset
for help on using the changeset viewer.