aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-12 17:56:27 +0200
committerDavid Robillard <d@drobilla.net>2022-01-13 23:03:50 -0500
commitc4df0038bcfba1676bbaaa98badd241ec7d0b55e (patch)
treeac16f53705066640efa3fd7eaaaf888923252017 /src/world.c
parent1752a00ebefb22564fb805d4c89deb39ec5e218b (diff)
downloadserd-c4df0038bcfba1676bbaaa98badd241ec7d0b55e.tar.gz
serd-c4df0038bcfba1676bbaaa98badd241ec7d0b55e.tar.bz2
serd-c4df0038bcfba1676bbaaa98badd241ec7d0b55e.zip
Add serd_world_get_blank()
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/world.c b/src/world.c
index e14a04c9..4413f433 100644
--- a/src/world.c
+++ b/src/world.c
@@ -16,6 +16,7 @@
#include "world.h"
+#include "node.h"
#include "serd_config.h"
#include "system.h"
@@ -27,6 +28,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#define BLANK_CHARS 12
FILE*
serd_world_fopen(SerdWorld* world, const char* path, const char* mode)
@@ -81,13 +85,32 @@ serd_world_errorf(const SerdWorld* const world,
SerdWorld*
serd_world_new(void)
{
- return (SerdWorld*)calloc(1, sizeof(SerdWorld));
+ SerdWorld* world = (SerdWorld*)calloc(1, sizeof(SerdWorld));
+
+ world->blank_node = serd_new_blank(SERD_STRING("b00000000000"));
+
+ return world;
}
void
serd_world_free(SerdWorld* const world)
{
- free(world);
+ if (world) {
+ serd_node_free(world->blank_node);
+ free(world);
+ }
+}
+
+const SerdNode*
+serd_world_get_blank(SerdWorld* const world)
+{
+ char* buf = serd_node_buffer(world->blank_node);
+ memset(buf, 0, BLANK_CHARS + 1);
+
+ world->blank_node->length =
+ (size_t)snprintf(buf, BLANK_CHARS + 1, "b%u", ++world->next_blank_id);
+
+ return world->blank_node;
}
void