diff options
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/world.c b/src/world.c index 406956b1..c4787aba 100644 --- a/src/world.c +++ b/src/world.c @@ -5,10 +5,12 @@ #include "log.h" #include "memory.h" +#include "namespaces.h" #include "node.h" #include "serd/node.h" #include "serd/status.h" +#include "serd/string_view.h" #include "serd/world.h" #include <assert.h> @@ -25,19 +27,44 @@ serd_world_new(SerdAllocator* const allocator) SerdNode* blank_node = serd_node_new(actual, serd_a_blank_string("b00000000000")); - if (!world || !blank_node) { + SerdNodes* const nodes = serd_nodes_new(actual); + + if (!world || !blank_node || !nodes) { + serd_nodes_free(nodes); serd_node_free(actual, blank_node); serd_afree(actual, world); return NULL; } + const SerdStringView rdf_first = serd_string(NS_RDF "first"); + const SerdStringView rdf_nil = serd_string(NS_RDF "nil"); + const SerdStringView rdf_rest = serd_string(NS_RDF "rest"); + const SerdStringView rdf_type = serd_string(NS_RDF "type"); + const SerdStringView xsd_boolean = serd_string(NS_XSD "boolean"); + const SerdStringView xsd_decimal = serd_string(NS_XSD "decimal"); + const SerdStringView xsd_integer = serd_string(NS_XSD "integer"); + world->limits.reader_stack_size = 1048576U; world->limits.writer_max_depth = 128U; world->allocator = actual; + world->nodes = nodes; world->blank_node = blank_node; serd_log_init(&world->log); + if (!(world->rdf_first = serd_nodes_get(nodes, serd_a_uri(rdf_first))) || + !(world->rdf_nil = serd_nodes_get(nodes, serd_a_uri(rdf_nil))) || + !(world->rdf_rest = serd_nodes_get(nodes, serd_a_uri(rdf_rest))) || + !(world->rdf_type = serd_nodes_get(nodes, serd_a_uri(rdf_type))) || + !(world->xsd_boolean = serd_nodes_get(nodes, serd_a_uri(xsd_boolean))) || + !(world->xsd_decimal = serd_nodes_get(nodes, serd_a_uri(xsd_decimal))) || + !(world->xsd_integer = serd_nodes_get(nodes, serd_a_uri(xsd_integer)))) { + serd_nodes_free(nodes); + serd_node_free(actual, blank_node); + serd_afree(actual, world); + return NULL; + } + return world; } @@ -46,6 +73,7 @@ serd_world_free(SerdWorld* const world) { if (world) { serd_node_free(world->allocator, world->blank_node); + serd_nodes_free(world->nodes); serd_afree(world->allocator, world); } } @@ -90,3 +118,10 @@ serd_world_allocator(const SerdWorld* const world) assert(world->allocator); return world->allocator; } + +SerdNodes* +serd_world_nodes(SerdWorld* const world) +{ + assert(world); + return world->nodes; +} |