aboutsummaryrefslogtreecommitdiffstats
path: root/src/env.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 /src/env.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 'src/env.c')
-rw-r--r--src/env.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/env.c b/src/env.c
index a6f1b5a9..71cb196f 100644
--- a/src/env.c
+++ b/src/env.c
@@ -32,6 +32,7 @@ typedef struct {
} SerdPrefix;
struct SerdEnvImpl {
+ SerdWorld* world;
SerdNodes* nodes;
SerdPrefix* prefixes;
size_t n_prefixes;
@@ -40,10 +41,13 @@ struct SerdEnvImpl {
};
SerdEnv*
-serd_env_new(const SerdStringView base_uri)
+serd_env_new(SerdWorld* const world, const SerdStringView base_uri)
{
+ assert(world);
+
SerdEnv* env = (SerdEnv*)calloc(1, sizeof(struct SerdEnvImpl));
+ env->world = world;
env->nodes = serd_nodes_new();
if (env && base_uri.len) {
@@ -62,6 +66,7 @@ serd_env_copy(const SerdEnv* const env)
SerdEnv* copy = (SerdEnv*)calloc(1, sizeof(struct SerdEnvImpl));
if (copy) {
+ copy->world = env->world;
copy->nodes = serd_nodes_new();
copy->n_prefixes = env->n_prefixes;
@@ -115,6 +120,12 @@ serd_env_equals(const SerdEnv* const a, const SerdEnv* const b)
return true;
}
+SerdWorld*
+serd_env_world(const SerdEnv* const env)
+{
+ return env->world;
+}
+
SerdURIView
serd_env_base_uri_view(const SerdEnv* const env)
{