aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-08-01 17:23:24 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commit5a39e907a9a1fad87c35a94ea1e534deeb2316f9 (patch)
tree9c7779da725f178d12c6b9c8e786e9143eb71b1c
parent633300d4f09f9c6000923dce35bb4a7302d6d92c (diff)
downloadserd-5a39e907a9a1fad87c35a94ea1e534deeb2316f9.tar.gz
serd-5a39e907a9a1fad87c35a94ea1e534deeb2316f9.tar.bz2
serd-5a39e907a9a1fad87c35a94ea1e534deeb2316f9.zip
Make serd_writer_set_root_uri() take a string view
This is generally more convenient, and the node was just being copied anyway.
-rw-r--r--include/serd/serd.h3
-rw-r--r--src/serdi.c4
-rw-r--r--src/writer.c6
3 files changed, 5 insertions, 8 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index f9a60354..790dfde0 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -2556,8 +2556,7 @@ serd_writer_set_base_uri(SerdWriter* SERD_NONNULL writer,
*/
SERD_API
SerdStatus
-serd_writer_set_root_uri(SerdWriter* SERD_NONNULL writer,
- const SerdNode* SERD_NULLABLE uri);
+serd_writer_set_root_uri(SerdWriter* SERD_NONNULL writer, SerdStringView uri);
/**
Finish a write.
diff --git a/src/serdi.c b/src/serdi.c
index ef5a7633..2de41ce7 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -478,9 +478,7 @@ main(int argc, char** argv)
}
if (root_uri) {
- SerdNode* const root = serd_new_uri(SERD_STRING(root_uri));
- serd_writer_set_root_uri(writer, root);
- serd_node_free(root);
+ serd_writer_set_root_uri(writer, SERD_STRING(root_uri));
}
serd_writer_chop_blank_prefix(writer, chop_prefix);
diff --git a/src/writer.c b/src/writer.c
index e56f0b75..968d1a9f 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -1389,7 +1389,7 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
}
SerdStatus
-serd_writer_set_root_uri(SerdWriter* writer, const SerdNode* uri)
+serd_writer_set_root_uri(SerdWriter* writer, const SerdStringView uri)
{
assert(writer);
@@ -1397,8 +1397,8 @@ serd_writer_set_root_uri(SerdWriter* writer, const SerdNode* uri)
writer->root_node = NULL;
writer->root_uri = SERD_URI_NULL;
- if (uri) {
- writer->root_node = serd_node_copy(uri);
+ if (uri.len) {
+ writer->root_node = serd_new_uri(uri);
writer->root_uri = serd_node_uri_view(writer->root_node);
}