Mercurial > hg
changeset 894:f76b32ff2f14
done_completion(): free all allocated memory
Free the completion list when a completion is done.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 02 Jun 2006 19:13:00 +0200 |
parents | 92aaf2af786b |
children | b461d7ee6d96 |
files | mcabber/src/compl.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;