summaryrefslogtreecommitdiffstats
path: root/src/sord.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-24 18:55:13 +0000
committerDavid Robillard <d@drobilla.net>2011-05-24 18:55:13 +0000
commit6dd5b9a2a403347dccdfaa769427fd7ca4955695 (patch)
treea17757775d5c51c71f4145680ea298757be1043f /src/sord.c
parentf44b324a36ce7d6238ed58eb67702e6a821deec7 (diff)
downloadsord-6dd5b9a2a403347dccdfaa769427fd7ca4955695.tar.gz
sord-6dd5b9a2a403347dccdfaa769427fd7ca4955695.tar.bz2
sord-6dd5b9a2a403347dccdfaa769427fd7ca4955695.zip
Free all nodes on world destruction (fix memory leaks).
git-svn-id: http://svn.drobilla.net/sord/trunk@132 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src/sord.c')
-rw-r--r--src/sord.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sord.c b/src/sord.c
index fa9c074..17f90e5 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -169,9 +169,22 @@ sord_world_new(void)
return world;
}
+static void
+free_hash_entry(void* key, void* value, void* user_data)
+{
+ SordNode* node = (SordNode*)value;
+ if (node->node.type == SERD_LITERAL) {
+ sord_node_free((SordWorld*)user_data, node->datatype);
+ }
+ g_free((uint8_t*)node->node.buf);
+ free(node);
+}
+
void
sord_world_free(SordWorld* world)
{
+ g_hash_table_foreach(world->literals, free_hash_entry, world);
+ g_hash_table_foreach(world->names, free_hash_entry, world);
g_hash_table_unref(world->names);
g_hash_table_unref(world->langs);
g_hash_table_unref(world->literals);