comparison mcabber/src/compl.c @ 1076:b9698c89f46d

Fix memory leak in scr_handle_tab()
author Mikael Berthe <mikael@lilotux.net>
date Sun, 03 Dec 2006 21:15:37 +0100
parents f76b32ff2f14
children 2de8f8ba1f34
comparison
equal deleted inserted replaced
1075:03bc225ad763 1076:b9698c89f46d
200 } 200 }
201 } 201 }
202 202
203 // compl_get_category_list() 203 // compl_get_category_list()
204 // Returns a slist of all words in the categories specified by the given flags 204 // Returns a slist of all words in the categories specified by the given flags
205 GSList *compl_get_category_list(guint cat_flags) 205 // Iff this function sets *dynlist to TRUE, then the caller must free the
206 // whole list after use.
207 GSList *compl_get_category_list(guint cat_flags, guint *dynlist)
206 { 208 {
207 GSList *sl_cat; 209 GSList *sl_cat;
210
211 *dynlist = FALSE;
212
208 // Look for category 213 // Look for category
209 // XXX Actually that's not that simple... cat_flags can be a combination 214 // XXX Actually that's not that simple... cat_flags can be a combination
210 // of several flags! 215 // of several flags!
211 for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) { 216 for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) {
212 if (cat_flags == ((category*)sl_cat->data)->flag) 217 if (cat_flags == ((category*)sl_cat->data)->flag)
214 } 219 }
215 if (sl_cat) // Category was found, easy... 220 if (sl_cat) // Category was found, easy...
216 return ((category*)sl_cat->data)->words; 221 return ((category*)sl_cat->data)->words;
217 222
218 // Handle dynamic SLists 223 // Handle dynamic SLists
224 *dynlist = TRUE;
219 if (cat_flags == COMPL_GROUPNAME) { 225 if (cat_flags == COMPL_GROUPNAME) {
220 return compl_list(ROSTER_TYPE_GROUP); 226 return compl_list(ROSTER_TYPE_GROUP);
221 } 227 }
222 if (cat_flags == COMPL_JID) { 228 if (cat_flags == COMPL_JID) {
223 return compl_list(ROSTER_TYPE_USER); 229 return compl_list(ROSTER_TYPE_USER);
227 } 233 }
228 if (cat_flags == COMPL_EVENTSID) { 234 if (cat_flags == COMPL_EVENTSID) {
229 return evs_geteventslist(TRUE); 235 return evs_geteventslist(TRUE);
230 } 236 }
231 237
238 *dynlist = FALSE;
232 return NULL; 239 return NULL;
233 } 240 }
234 241
235 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ 242 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */