aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_reader_writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-10 13:20:47 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commiteb804125430e3445e85c423b28e1c41346772ed0 (patch)
tree532f6995ace537170fbbfde2d0d8226d1a48279b /test/test_reader_writer.c
parentcbf01be4126cbc0f6d80364a7e0b6ad777a7d8ae (diff)
downloadserd-eb804125430e3445e85c423b28e1c41346772ed0.tar.gz
serd-eb804125430e3445e85c423b28e1c41346772ed0.tar.bz2
serd-eb804125430e3445e85c423b28e1c41346772ed0.zip
Make environments and sinks part of the world
Although functions/components that require minimal pre-existing state are nice, these allocate memory and could potentially share resources. So, give them a pointer to a world which can be used to configure such things. In particular, this is working towards supporting custom allocators everywhere.
Diffstat (limited to 'test/test_reader_writer.c')
-rw-r--r--test/test_reader_writer.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 8bb76083..52be8d74 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -36,11 +36,11 @@ count_statements(void* handle, const SerdEvent* event)
static void
test_writer(const char* const path)
{
- FILE* fd = fopen(path, "wb");
- SerdEnv* env = serd_env_new(SERD_EMPTY_STRING());
+ FILE* fd = fopen(path, "wb");
+ SerdWorld* world = serd_world_new();
+ SerdEnv* env = serd_env_new(world, SERD_EMPTY_STRING());
assert(fd);
- SerdWorld* world = serd_world_new();
SerdNodes* nodes = serd_world_nodes(world);
SerdOutputStream output = serd_open_output_file(path);
@@ -133,12 +133,15 @@ test_writer(const char* const path)
static void
test_reader(const char* path)
{
- SerdWorld* world = serd_world_new();
- size_t n_statements = 0;
- SerdSink* const sink = serd_sink_new(&n_statements, count_statements, NULL);
+ SerdWorld* world = serd_world_new();
+ size_t n_statements = 0;
+
+ SerdSink* const sink =
+ serd_sink_new(world, &n_statements, count_statements, NULL);
+
assert(sink);
- SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING());
+ SerdEnv* const env = serd_env_new(world, SERD_EMPTY_STRING());
assert(env);
// Test that too little stack space fails gracefully