aboutsummaryrefslogtreecommitdiffstats
path: root/src/serdi.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-25 17:03:53 +0000
committerDavid Robillard <d@drobilla.net>2011-01-25 17:03:53 +0000
commit5b0c4fec31b17b92d01f4eeccfd4bc4af8484865 (patch)
tree24c8a2b3a74678ce9d6d59860a2a7525a844c378 /src/serdi.c
parent2e3ec18723e534dd1e6600148a2e24216138414d (diff)
downloadserd-5b0c4fec31b17b92d01f4eeccfd4bc4af8484865.tar.gz
serd-5b0c4fec31b17b92d01f4eeccfd4bc4af8484865.tar.bz2
serd-5b0c4fec31b17b92d01f4eeccfd4bc4af8484865.zip
Fix memory leaks.
Push builtin URIs (rdf:type, etc) on parser creation/deletion, rather than at each parse. git-svn-id: http://svn.drobilla.net/serd/trunk@67 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/serdi.c')
-rw-r--r--src/serdi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 467c3275..5ab5e440 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -56,6 +56,7 @@ string_sink(const void* buf, size_t len, void* stream)
return len;
}
+// FIXME: doesn't belong here
static SerdNode
serd_node_new_uri(const SerdURI* uri, SerdURI* out)
{
@@ -86,6 +87,13 @@ serd_node_new_uri(const SerdURI* uri, SerdURI* out)
return node;
}
+// FIXME: doesn't belong here
+static void
+serd_node_free(SerdNode* node)
+{
+ free((uint8_t*)node->buf); // FIXME: ick, const cast
+}
+
static uint8_t*
copy_string(const uint8_t* str, size_t* n_bytes)
{
@@ -113,7 +121,8 @@ event_base(void* handle,
return false;
}
base_uri_node = serd_node_new_uri(&abs_base_uri, &base_uri);
-
+
+ serd_node_free(&state->base_uri_node);
state->base_uri_node = base_uri_node;
state->base_uri = base_uri;
serd_writer_set_base_uri(state->writer, &base_uri);
@@ -138,6 +147,7 @@ event_prefix(void* handle,
SerdURI base_uri;
SerdNode base_uri_node = serd_node_new_uri(&abs_uri, &base_uri);
serd_env_add(state->env, name, &base_uri_node);
+ serd_node_free(&base_uri_node);
} else {
serd_env_add(state->env, name, uri_node);
}
@@ -288,7 +298,8 @@ main(int argc, char** argv)
serd_writer_free(state.writer);
serd_env_free(state.env);
- free(base_uri_str);
+
+ serd_node_free(&state.base_uri_node);
if (success) {
return 0;