summaryrefslogtreecommitdiffstats
path: root/src/value.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-27 21:23:25 +0000
committerDavid Robillard <d@drobilla.net>2011-04-27 21:23:25 +0000
commit03e318d5d80b0cfda96efc58e270693eeabe9a79 (patch)
treea8c139d374fb09e951b5373bde71eb53b9d4309e /src/value.c
parent3c1b7c2b6633cc1afee350f12d0bd7a7b3eeafa5 (diff)
downloadlilv-03e318d5d80b0cfda96efc58e270693eeabe9a79.tar.gz
lilv-03e318d5d80b0cfda96efc58e270693eeabe9a79.tar.bz2
lilv-03e318d5d80b0cfda96efc58e270693eeabe9a79.zip
Fix memory leaks.
Don't modify model while reading it. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3199 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/value.c')
-rw-r--r--src/value.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/value.c b/src/value.c
index fd53197..e39e860 100644
--- a/src/value.c
+++ b/src/value.c
@@ -68,7 +68,8 @@ SLV2Value
slv2_value_new(SLV2World world, SLV2ValueType type, const char* str)
{
SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
- val->type = type;
+ val->world = world;
+ val->type = type;
switch (type) {
case SLV2_VALUE_URI:
@@ -101,6 +102,7 @@ slv2_value_new_from_node(SLV2World world, SordNode node)
case SORD_URI:
type = SLV2_VALUE_URI;
result = (SLV2Value)malloc(sizeof(struct _SLV2Value));
+ result->world = world;
result->type = SLV2_VALUE_URI;
result->val.uri_val = slv2_node_copy(node);
result->str_val = (char*)sord_node_get_string(result->val.uri_val);
@@ -192,6 +194,7 @@ slv2_value_duplicate(SLV2Value val)
return val;
SLV2Value result = (SLV2Value)malloc(sizeof(struct _SLV2Value));
+ result->world = val->world;
result->type = val->type;
if (val->type == SLV2_VALUE_URI) {
@@ -210,7 +213,9 @@ void
slv2_value_free(SLV2Value val)
{
if (val) {
- if (val->type != SLV2_VALUE_URI) {
+ if (val->type == SLV2_VALUE_URI) {
+ slv2_node_free(val->world, val->val.uri_val);
+ } else {
free(val->str_val);
}
free(val);