Added stanza free functions

This commit is contained in:
James Booth
2015-05-17 20:36:11 +01:00
parent f7b3be3699
commit 2e1a2f7c14
3 changed files with 37 additions and 4 deletions

View File

@@ -163,3 +163,33 @@ stanza_get_id(XMPPStanza *stanza)
return NULL;
}
static void
_attrs_free(XMPPAttr *attr)
{
if (attr) {
free(attr->name);
free(attr->value);
free(attr);
}
}
static void
_stanza_free(XMPPStanza *stanza)
{
if (stanza) {
free(stanza->name);
if (stanza->content) {
g_string_free(stanza->content, TRUE);
}
g_list_free_full(stanza->attrs, (GDestroyNotify)_attrs_free);
g_list_free_full(stanza->children, (GDestroyNotify)_stanza_free);
free(stanza);
}
}
void
stanza_free_all(void)
{
g_list_free_full(stanzas, (GDestroyNotify)_stanza_free);
}