Mercurial > hg
comparison mcabber/src/compl.c @ 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 | 80bd7f49075f |
children | b9698c89f46d |
comparison
equal
deleted
inserted
replaced
893:92aaf2af786b | 894:f76b32ff2f14 |
---|---|
53 static compl *InputCompl; | 53 static compl *InputCompl; |
54 | 54 |
55 // new_completion(prefix, compl_cat) | 55 // new_completion(prefix, compl_cat) |
56 // . prefix = beginning of the word, typed by the user | 56 // . prefix = beginning of the word, typed by the user |
57 // . compl_cat = pointer to a completion category list (list of *char) | 57 // . compl_cat = pointer to a completion category list (list of *char) |
58 // Returns a pointer to an allocated compl structure. This structure should | 58 // Set the InputCompl pointer to an allocated compl structure. |
59 // be freed by the caller when not used anymore. | 59 // done_completion() must be called when finished. |
60 void new_completion(char *prefix, GSList *compl_cat) | 60 void new_completion(char *prefix, GSList *compl_cat) |
61 { | 61 { |
62 compl *c; | 62 compl *c; |
63 GSList *sl_cat; | 63 GSList *sl_cat; |
64 size_t len = strlen(prefix); | 64 size_t len = strlen(prefix); |
81 } | 81 } |
82 | 82 |
83 // done_completion(); | 83 // done_completion(); |
84 void done_completion(void) | 84 void done_completion(void) |
85 { | 85 { |
86 GSList *clp; | |
87 | |
86 if (!InputCompl) return; | 88 if (!InputCompl) return; |
87 | 89 |
88 // TODO free everything | 90 // Free the current completion list |
91 for (clp = InputCompl->list; clp; clp = g_slist_next(clp)) | |
92 g_free(clp->data); | |
89 g_slist_free(InputCompl->list); | 93 g_slist_free(InputCompl->list); |
90 g_free(InputCompl); | 94 g_free(InputCompl); |
91 InputCompl = NULL; | 95 InputCompl = NULL; |
92 } | 96 } |
93 | 97 |