diff options
author | David Robillard <d@drobilla.net> | 2021-09-10 13:20:47 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | eb804125430e3445e85c423b28e1c41346772ed0 (patch) | |
tree | 532f6995ace537170fbbfde2d0d8226d1a48279b /src/env.c | |
parent | cbf01be4126cbc0f6d80364a7e0b6ad777a7d8ae (diff) | |
download | serd-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.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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) { |