aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-07-23 12:21:57 -0400
committerDavid Robillard <d@drobilla.net>2022-01-14 19:37:51 -0500
commit34852e8faa380f12b11522cfa998df4f260e3856 (patch)
tree4aff80f3b67eb29ea827f7eb02bb027d3c9fb323 /src/world.c
parent1f783d27991dabb3b8312db8970cd1778a6ae3e6 (diff)
downloadserd-34852e8faa380f12b11522cfa998df4f260e3856.tar.gz
serd-34852e8faa380f12b11522cfa998df4f260e3856.tar.bz2
serd-34852e8faa380f12b11522cfa998df4f260e3856.zip
Avoid dynamic allocation of world blank node
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/world.c b/src/world.c
index 5af8c3d4..58efac90 100644
--- a/src/world.c
+++ b/src/world.c
@@ -79,6 +79,7 @@ serd_world_new(void)
const SerdStringView xsd_decimal = SERD_STRING(NS_XSD "decimal");
const SerdStringView xsd_integer = SERD_STRING(NS_XSD "integer");
+ world->nodes = nodes;
world->rdf_first = serd_nodes_uri(nodes, rdf_first);
world->rdf_nil = serd_nodes_uri(nodes, rdf_nil);
world->rdf_rest = serd_nodes_uri(nodes, rdf_rest);
@@ -87,8 +88,10 @@ serd_world_new(void)
world->xsd_decimal = serd_nodes_uri(nodes, xsd_decimal);
world->xsd_integer = serd_nodes_uri(nodes, xsd_integer);
- world->blank_node = serd_new_token(SERD_BLANK, SERD_STRING("b00000000000"));
- world->nodes = nodes;
+ serd_node_construct_token(sizeof(world->blank),
+ &world->blank,
+ SERD_BLANK,
+ SERD_STRING("b00000000000"));
world->stderr_color = terminal_supports_color(stderr);
@@ -99,7 +102,6 @@ void
serd_world_free(SerdWorld* const world)
{
if (world) {
- serd_node_free(world->blank_node);
serd_nodes_free(world->nodes);
free(world);
}
@@ -114,11 +116,11 @@ serd_world_nodes(SerdWorld* const world)
const SerdNode*
serd_world_get_blank(SerdWorld* const world)
{
- char* buf = serd_node_buffer(world->blank_node);
+ char* buf = world->blank.string;
memset(buf, 0, BLANK_CHARS + 1);
- world->blank_node->length =
+ world->blank.node.length =
(size_t)snprintf(buf, BLANK_CHARS + 1, "b%u", ++world->next_blank_id);
- return world->blank_node;
+ return &world->blank.node;
}