aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/world.c b/src/world.c
index 90033ff5..ebafcfef 100644
--- a/src/world.c
+++ b/src/world.c
@@ -18,6 +18,7 @@
#include "world.h"
+#include "node.h"
#include "serd_config.h"
#if defined(HAVE_POSIX_FADVISE)
@@ -30,6 +31,8 @@
#include <stdlib.h>
#include <string.h>
+#define BLANK_CHARS 11
+
FILE*
serd_world_fopen(SerdWorld* world, const char* path, const char* mode)
{
@@ -76,13 +79,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)
{
- free(world);
+ if (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