summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-06-09 05:48:48 +0000
committerDavid Robillard <d@drobilla.net>2011-06-09 05:48:48 +0000
commit3b333151e8d9b245d10d28b8f5c427e3d33a1c66 (patch)
tree3a84dbdf40f6c8e9cf5e2bd8fac4c42779fa0660
parent2af0d830244b5b504b1bd28c3660e9f441520856 (diff)
downloadlilv-3b333151e8d9b245d10d28b8f5c427e3d33a1c66.tar.gz
lilv-3b333151e8d9b245d10d28b8f5c427e3d33a1c66.tar.bz2
lilv-3b333151e8d9b245d10d28b8f5c427e3d33a1c66.zip
Explicitly document free functions as safe to call on NULL.
Fix ticket #709. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3377 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--lilv/lilv.h11
-rw-r--r--src/scalepoint.c8
-rw-r--r--src/world.c4
3 files changed, 16 insertions, 7 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h
index 305e8e1..b5a84e7 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -145,14 +145,15 @@ LilvNode*
lilv_new_bool(LilvWorld* world, bool val);
/**
- Free an LilvNode.
+ Free a LilvNode.
+ It is safe to call this function on NULL.
*/
LILV_API
void
lilv_node_free(LilvNode* val);
/**
- Duplicate an LilvNode.
+ Duplicate a LilvNode.
*/
LILV_API
LilvNode*
@@ -538,6 +539,7 @@ lilv_world_set_option(LilvWorld* world,
/**
Destroy the world, mwahaha.
+ It is safe to call this function on NULL.
Note that destroying @a world will destroy all the objects it contains
(e.g. instances of LilvPlugin). Do not destroy the world until you are
finished with all objects that came from it.
@@ -722,7 +724,7 @@ lilv_plugin_get_class(const LilvPlugin* plugin);
<code>&lt;plugin-uri&gt; predicate ?object</code>
May return NULL if the property was not found, or if object(s) is not
- sensibly represented as an LilvNodes (e.g. blank nodes).
+ sensibly represented as a LilvNodes (e.g. blank nodes).
Return value must be freed by caller with lilv_nodes_free.
*/
LILV_API
@@ -974,7 +976,7 @@ lilv_port_get_classes(const LilvPlugin* plugin,
/**
Determine if a port is of a given class (input, output, audio, etc).
For convenience/performance/extensibility reasons, hosts are expected to
- create an LilvNode for each port class they "care about". Well-known type
+ create a LilvNode for each port class they "care about". Well-known type
URI strings are defined (e.g. LILV_PORT_CLASS_INPUT) for convenience, but
this function is designed so that Lilv is usable with any port types
without requiring explicit support in Lilv.
@@ -1118,6 +1120,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
/**
Free a plugin instance.
+ It is safe to call this function on NULL.
@a instance is invalid after this call.
*/
LILV_API
diff --git a/src/scalepoint.c b/src/scalepoint.c
index 6995b85..0138e61 100644
--- a/src/scalepoint.c
+++ b/src/scalepoint.c
@@ -30,9 +30,11 @@ lilv_scale_point_new(LilvNode* value, LilvNode* label)
void
lilv_scale_point_free(LilvScalePoint* point)
{
- lilv_node_free(point->value);
- lilv_node_free(point->label);
- free(point);
+ if (point) {
+ lilv_node_free(point->value);
+ lilv_node_free(point->label);
+ free(point);
+ }
}
LILV_API
diff --git a/src/world.c b/src/world.c
index e2456dd..e94bcd8 100644
--- a/src/world.c
+++ b/src/world.c
@@ -100,6 +100,10 @@ LILV_API
void
lilv_world_free(LilvWorld* world)
{
+ if (!world) {
+ return NULL;
+ }
+
lilv_plugin_class_free(world->lv2_plugin_class);
world->lv2_plugin_class = NULL;