# HG changeset patch # User Mikael Berthe # Date 1149268380 -7200 # Node ID f76b32ff2f14453d7fe95342f5a9e56f086c05fc # Parent 92aaf2af786bfd2377c4d8c10805e189cdc7e5e5 done_completion(): free all allocated memory Free the completion list when a completion is done. diff -r 92aaf2af786b -r f76b32ff2f14 mcabber/src/compl.c --- a/mcabber/src/compl.c Thu Jun 01 18:55:55 2006 +0200 +++ b/mcabber/src/compl.c Fri Jun 02 19:13:00 2006 +0200 @@ -55,8 +55,8 @@ // new_completion(prefix, compl_cat) // . prefix = beginning of the word, typed by the user // . compl_cat = pointer to a completion category list (list of *char) -// Returns a pointer to an allocated compl structure. This structure should -// be freed by the caller when not used anymore. +// Set the InputCompl pointer to an allocated compl structure. +// done_completion() must be called when finished. void new_completion(char *prefix, GSList *compl_cat) { compl *c; @@ -83,9 +83,13 @@ // done_completion(); void done_completion(void) { + GSList *clp; + if (!InputCompl) return; - // TODO free everything + // Free the current completion list + for (clp = InputCompl->list; clp; clp = g_slist_next(clp)) + g_free(clp->data); g_slist_free(InputCompl->list); g_free(InputCompl); InputCompl = NULL;