summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-03-14 21:23:34 -0400
committerDavid Robillard <d@drobilla.net>2022-03-14 21:23:34 -0400
commit3fe2e0ea0c285150672054ee2717307c4d7b189f (patch)
tree272c0b60ce38ab6463237c7c21555c1cb7ead8c3
parent65e718da3a8154560b9451c273ce94eb195fa71a (diff)
downloadlilv-3fe2e0ea0c285150672054ee2717307c4d7b189f.tar.gz
lilv-3fe2e0ea0c285150672054ee2717307c4d7b189f.tar.bz2
lilv-3fe2e0ea0c285150672054ee2717307c4d7b189f.zip
fixup! WIP: Port to serd1serd1
-rw-r--r--src/collections.c4
-rw-r--r--src/port.c41
-rw-r--r--src/state.c13
-rw-r--r--src/world.c10
4 files changed, 46 insertions, 22 deletions
diff --git a/src/collections.c b/src/collections.c
index 04b0c51..06b402e 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -30,7 +30,9 @@ lilv_ptr_cmp(const void* a, const void* b, const void* user_data)
{
(void)user_data;
- return (intptr_t)a - (intptr_t)b;
+ return ((uintptr_t)a < (uintptr_t)b) ? -1
+ : ((uintptr_t)b < (uintptr_t)a) ? 1
+ : 0;
}
int
diff --git a/src/port.c b/src/port.c
index fa3d122..cd060fa 100644
--- a/src/port.c
+++ b/src/port.c
@@ -88,19 +88,25 @@ lilv_port_supports_event(const LilvPlugin* plugin,
const LilvPort* port,
const LilvNode* event_type)
{
- const char* predicates[] = {
- LV2_EVENT__supportsEvent, LV2_ATOM__supports, NULL};
-
- for (const char** pred = predicates; *pred; ++pred) {
- if (serd_model_ask(plugin->world->model,
- port->node,
- serd_new_uri(NULL, serd_string(*pred)),
- event_type,
- NULL)) {
- return true;
+ SerdNode* predicates[] = {
+ serd_new_uri(NULL, serd_string(LV2_EVENT__supportsEvent)),
+ serd_new_uri(NULL, serd_string(LV2_ATOM__supports)),
+ NULL};
+
+ bool supported = false;
+
+ for (SerdNode** pred = predicates; *pred; ++pred) {
+ if ((supported = serd_model_ask(
+ plugin->world->model, port->node, *pred, event_type, NULL))) {
+ break;
}
}
- return false;
+
+ for (SerdNode** pred = predicates; *pred; ++pred) {
+ serd_node_free(NULL, *pred);
+ }
+
+ return supported;
}
static LilvNodes*
@@ -229,12 +235,13 @@ lilv_port_get_range(const LilvPlugin* plugin,
LilvScalePoints*
lilv_port_get_scale_points(const LilvPlugin* plugin, const LilvPort* port)
{
- SerdCursor* points =
- serd_model_find(plugin->world->model,
- port->node,
- serd_new_uri(NULL, serd_string(LV2_CORE__scalePoint)),
- NULL,
- NULL);
+ SerdNode* const lv2_scalePoint =
+ serd_new_uri(NULL, serd_string(LV2_CORE__scalePoint));
+
+ SerdCursor* const points = serd_model_find(
+ plugin->world->model, port->node, lv2_scalePoint, NULL, NULL);
+
+ serd_node_free(NULL, lv2_scalePoint);
LilvScalePoints* ret = NULL;
if (!serd_cursor_is_end(points)) {
diff --git a/src/state.c b/src/state.c
index 4b3fa06..f651879 100644
--- a/src/state.c
+++ b/src/state.c
@@ -665,8 +665,8 @@ new_state_from_model(LilvWorld* world,
const SerdNode* graph = serd_statement_graph(s);
state->label = lilv_strdup(serd_node_string(object));
set_state_dir_from_model(state, graph);
- serd_cursor_free(i);
}
+ serd_cursor_free(i);
SerdEnv* env = serd_env_new(world->world, serd_empty_string());
SratomLoader* loader = sratom_loader_new(world->world, map);
@@ -732,6 +732,7 @@ new_state_from_model(LilvWorld* world,
serd_free(NULL, buffer.buf);
sratom_loader_free(loader);
+ serd_env_free(env);
if (state->props.props) {
qsort(state->props.props, state->props.n, sizeof(Property), property_cmp);
@@ -799,6 +800,7 @@ lilv_state_new_from_file(LilvWorld* world,
serd_node_free(NULL, node);
free(abs_path);
serd_reader_free(reader);
+ serd_sink_free(inserter);
serd_model_free(model);
serd_env_free(env);
return state;
@@ -847,6 +849,7 @@ lilv_state_new_from_string(LilvWorld* world, LV2_URID_Map* map, const char* str)
serd_node_free(NULL, o);
serd_reader_free(reader);
+ serd_sink_free(inserter);
serd_model_free(model);
serd_env_free(env);
@@ -1000,6 +1003,7 @@ add_state_to_manifest(LilvWorld* lworld,
write_manifest(lworld, env, model, manifest);
serd_node_free(NULL, s);
+ serd_sink_free(inserter);
serd_model_free(model);
serd_node_free(NULL, file);
serd_node_free(NULL, manifest);
@@ -1154,7 +1158,9 @@ lilv_state_write(LilvWorld* world,
value->atom,
0); // SRATOM_PRETTY_NUMBERS);
- if ((st = serd_sink_write_end(sink, port))) {
+ st = serd_sink_write_end(sink, port);
+ serd_node_free(NULL, port);
+ if (st) {
return st;
}
}
@@ -1182,6 +1188,7 @@ lilv_state_write(LilvWorld* world,
serd_node_free(NULL, body);
sratom_dumper_free(dumper);
+ serd_node_free(NULL, subject);
return SERD_SUCCESS;
}
@@ -1321,6 +1328,7 @@ lilv_state_to_string(LilvWorld* world,
char* str = (char*)buffer.buf;
char* result = lilv_strdup(str); // FIXME: Alloc in lilv to avoid this (win32)
serd_free(NULL, str);
+ serd_node_free(NULL, base);
return result;
}
@@ -1371,6 +1379,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
serd_reader_read_document(reader);
serd_close_input(&in);
serd_reader_free(reader);
+ serd_sink_free(inserter);
serd_env_free(env);
}
diff --git a/src/world.c b/src/world.c
index 9a311a9..5153637 100644
--- a/src/world.c
+++ b/src/world.c
@@ -619,9 +619,12 @@ lilv_world_get_manifest_node(LilvWorld* world, const LilvNode* bundle_node)
char*
lilv_world_get_manifest_path(LilvWorld* world, const LilvNode* bundle_node)
{
- const SerdNode* const node = lilv_world_get_manifest_node(world, bundle_node);
+ SerdNode* const node = lilv_world_get_manifest_node(world, bundle_node);
- return serd_parse_file_uri(NULL, serd_node_string(node), NULL);
+ char* const path = serd_parse_file_uri(NULL, serd_node_string(node), NULL);
+
+ serd_node_free(NULL, node);
+ return path;
}
static SerdModel*
@@ -645,6 +648,7 @@ load_plugin_model(LilvWorld* world,
serd_reader_read_document(reader);
serd_reader_finish(reader);
serd_close_input(&manifest_in);
+ serd_free(NULL, manifest_path);
// Load any seeAlso files
SerdModel* files = lilv_world_filter_model(
@@ -662,12 +666,14 @@ load_plugin_model(LilvWorld* world,
serd_reader_read_document(reader);
serd_reader_finish(reader);
serd_close_input(&in);
+ serd_free(NULL, path_str);
}
}
serd_cursor_free(f);
serd_model_free(files);
serd_reader_free(reader);
+ serd_sink_free(inserter);
serd_env_free(env);
return model;