diff options
-rw-r--r-- | src/world.c | 20 | ||||
-rw-r--r-- | src/world.h | 7 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/world.c b/src/world.c index c4787aba..37cfe301 100644 --- a/src/world.c +++ b/src/world.c @@ -23,15 +23,13 @@ serd_world_new(SerdAllocator* const allocator) SerdAllocator* const actual = allocator ? allocator : serd_default_allocator(); - SerdWorld* world = (SerdWorld*)serd_acalloc(actual, 1, sizeof(SerdWorld)); - SerdNode* blank_node = - serd_node_new(actual, serd_a_blank_string("b00000000000")); + SerdWorld* const world = + (SerdWorld*)serd_acalloc(actual, 1, sizeof(SerdWorld)); SerdNodes* const nodes = serd_nodes_new(actual); - if (!world || !blank_node || !nodes) { + if (!world || !nodes) { serd_nodes_free(nodes); - serd_node_free(actual, blank_node); serd_afree(actual, world); return NULL; } @@ -48,7 +46,6 @@ serd_world_new(SerdAllocator* const allocator) world->limits.writer_max_depth = 128U; world->allocator = actual; world->nodes = nodes; - world->blank_node = blank_node; serd_log_init(&world->log); @@ -60,11 +57,13 @@ serd_world_new(SerdAllocator* const allocator) !(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; } + serd_node_construct( + sizeof(world->blank), &world->blank, serd_a_blank_string("b00000000000")); + return world; } @@ -72,7 +71,6 @@ void 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); } @@ -100,13 +98,13 @@ serd_world_get_blank(SerdWorld* const world) assert(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; #undef BLANK_CHARS } diff --git a/src/world.h b/src/world.h index 0888b480..8033dcec 100644 --- a/src/world.h +++ b/src/world.h @@ -5,6 +5,7 @@ #define SERD_SRC_WORLD_H #include "log.h" +#include "node.h" #include "serd/memory.h" #include "serd/node.h" @@ -25,9 +26,13 @@ struct SerdWorldImpl { const SerdNode* xsd_boolean; const SerdNode* xsd_decimal; const SerdNode* xsd_integer; - SerdNode* blank_node; uint32_t next_blank_id; uint32_t next_document_id; + + struct { + SerdNode node; + char string[16]; + } blank; }; #endif // SERD_SRC_WORLD_H |