diff options
Diffstat (limited to 'src/env.c')
-rw-r--r-- | src/env.c | 32 |
1 files changed, 15 insertions, 17 deletions
@@ -4,7 +4,6 @@ #include "serd/env.h" #include "env.h" -#include "memory.h" #include "node.h" #include "serd/node.h" @@ -25,7 +24,7 @@ typedef struct { } SerdPrefix; struct SerdEnvImpl { - SerdAllocator* allocator; + ZixAllocator* allocator; SerdNodes* nodes; SerdPrefix* prefixes; size_t n_prefixes; @@ -34,22 +33,21 @@ struct SerdEnvImpl { }; SerdEnv* -serd_env_new(SerdAllocator* const allocator, const ZixStringView base_uri) +serd_env_new(ZixAllocator* const allocator, const ZixStringView base_uri) { - SerdEnv* env = - (SerdEnv*)serd_acalloc(allocator, 1, sizeof(struct SerdEnvImpl)); + SerdEnv* env = (SerdEnv*)zix_calloc(allocator, 1, sizeof(struct SerdEnvImpl)); if (env) { env->allocator = allocator; if (!(env->nodes = serd_nodes_new(allocator))) { - serd_afree(allocator, env); + zix_free(allocator, env); return NULL; } if (base_uri.length) { if (serd_env_set_base_uri(env, base_uri)) { serd_nodes_free(env->nodes); - serd_afree(allocator, env); + zix_free(allocator, env); return NULL; } } @@ -59,13 +57,13 @@ serd_env_new(SerdAllocator* const allocator, const ZixStringView base_uri) } SerdEnv* -serd_env_copy(SerdAllocator* const allocator, const SerdEnv* const env) +serd_env_copy(ZixAllocator* const allocator, const SerdEnv* const env) { if (!env) { return NULL; } - SerdEnv* const copy = (SerdEnv*)serd_acalloc(allocator, 1, sizeof(SerdEnv)); + SerdEnv* const copy = (SerdEnv*)zix_calloc(allocator, 1, sizeof(SerdEnv)); if (copy) { copy->allocator = allocator; copy->n_prefixes = env->n_prefixes; @@ -73,7 +71,7 @@ serd_env_copy(SerdAllocator* const allocator, const SerdEnv* const env) // Allocate structure and set base URI const SerdNode* const base = serd_env_base_uri(env); if (!(copy->nodes = serd_nodes_new(allocator)) || - !(copy->prefixes = (SerdPrefix*)serd_acalloc( + !(copy->prefixes = (SerdPrefix*)zix_calloc( allocator, copy->n_prefixes, sizeof(SerdPrefix))) || (base && serd_env_set_base_uri(copy, serd_node_string_view(base)))) { serd_env_free(copy); @@ -98,9 +96,9 @@ void serd_env_free(SerdEnv* const env) { if (env) { - serd_afree(env->allocator, env->prefixes); + zix_free(env->allocator, env->prefixes); serd_nodes_free(env->nodes); - serd_afree(env->allocator, env); + zix_free(env->allocator, env); } } @@ -187,7 +185,7 @@ serd_env_set_base_path(SerdEnv* const env, const ZixStringView path) const char path_last = path.data[path.length - 1]; if (path_last == '/' || path_last == '\\') { char* const base_path = - (char*)serd_acalloc(env->allocator, real_path_len + 2, 1); + (char*)zix_calloc(env->allocator, real_path_len + 2, 1); memcpy(base_path, real_path, real_path_len + 1); base_path[real_path_len] = path_last; @@ -195,7 +193,7 @@ serd_env_set_base_path(SerdEnv* const env, const ZixStringView path) base_node = serd_node_new( NULL, serd_a_file_uri(zix_string(base_path), zix_empty_string())); - serd_afree(env->allocator, base_path); + zix_free(env->allocator, base_path); } else { base_node = serd_node_new( NULL, serd_a_file_uri(zix_string(real_path), zix_empty_string())); @@ -259,9 +257,9 @@ serd_env_add(SerdEnv* const env, } SerdPrefix* const new_prefixes = - (SerdPrefix*)serd_arealloc(env->allocator, - env->prefixes, - (env->n_prefixes + 1) * sizeof(SerdPrefix)); + (SerdPrefix*)zix_realloc(env->allocator, + env->prefixes, + (env->n_prefixes + 1) * sizeof(SerdPrefix)); if (!new_prefixes) { return SERD_BAD_ALLOC; |