From e805c03be2bd1e9cee0ba5ce2c3f36f6fd913101 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 May 2018 17:56:27 +0200 Subject: Add serd_world_get_blank() --- src/world.c | 20 +++++++++++++++++++- src/world.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/world.c b/src/world.c index f95accf4..9908e4d4 100644 --- a/src/world.c +++ b/src/world.c @@ -18,6 +18,7 @@ #include "world.h" +#include "node.h" #include "serd_config.h" #include @@ -29,6 +30,8 @@ # include #endif +#define BLANK_CHARS 11 + FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode) { @@ -71,15 +74,30 @@ serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...) SerdWorld* serd_world_new(void) { - return (SerdWorld*)calloc(1, sizeof(SerdWorld)); + SerdWorld* world = (SerdWorld*)calloc(1, sizeof(SerdWorld)); + + world->blank_node = serd_node_new_blank("b0000000000"); + + return world; } void serd_world_free(SerdWorld* world) { + serd_node_free(world->blank_node); free(world); } +const SerdNode* +serd_world_get_blank(SerdWorld* world) +{ + char* buf = serd_node_buffer(world->blank_node); + memset(buf, 0, BLANK_CHARS + 1); + world->blank_node->n_bytes = snprintf( + buf, BLANK_CHARS, "b%u", ++world->next_blank_id); + return world->blank_node; +} + void serd_world_set_error_sink(SerdWorld* world, SerdErrorSink error_sink, diff --git a/src/world.h b/src/world.h index 0aaea8fc..201d038f 100644 --- a/src/world.h +++ b/src/world.h @@ -25,6 +25,8 @@ struct SerdWorldImpl { SerdErrorSink error_sink; void* error_handle; + uint32_t next_blank_id; + SerdNode* blank_node; }; FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode); -- cgit v1.2.1