diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/block_dumper.c | 4 | ||||
-rw-r--r-- | src/block_dumper.h | 4 | ||||
-rw-r--r-- | src/buffer.c | 5 | ||||
-rw-r--r-- | src/byte_source.c | 18 | ||||
-rw-r--r-- | src/byte_source.h | 6 | ||||
-rw-r--r-- | src/canon.c | 8 | ||||
-rw-r--r-- | src/caret.c | 18 | ||||
-rw-r--r-- | src/cursor.c | 11 | ||||
-rw-r--r-- | src/describe.c | 7 | ||||
-rw-r--r-- | src/env.c | 32 | ||||
-rw-r--r-- | src/filter.c | 25 | ||||
-rw-r--r-- | src/memory.c | 17 | ||||
-rw-r--r-- | src/memory.h | 97 | ||||
-rw-r--r-- | src/model.c | 19 | ||||
-rw-r--r-- | src/model.h | 4 | ||||
-rw-r--r-- | src/node.c | 29 | ||||
-rw-r--r-- | src/node.h | 10 | ||||
-rw-r--r-- | src/node_syntax.c | 18 | ||||
-rw-r--r-- | src/nodes.c | 44 | ||||
-rw-r--r-- | src/reader.c | 2 | ||||
-rw-r--r-- | src/sink.c | 14 | ||||
-rw-r--r-- | src/sink.h | 10 | ||||
-rw-r--r-- | src/stack.h | 13 | ||||
-rw-r--r-- | src/statement.c | 23 | ||||
-rw-r--r-- | src/string.c | 8 | ||||
-rw-r--r-- | src/uri.c | 19 | ||||
-rw-r--r-- | src/world.c | 20 | ||||
-rw-r--r-- | src/world.h | 4 | ||||
-rw-r--r-- | src/writer.c | 5 |
29 files changed, 189 insertions, 305 deletions
diff --git a/src/block_dumper.c b/src/block_dumper.c index 21a10fcc..837b37e9 100644 --- a/src/block_dumper.c +++ b/src/block_dumper.c @@ -6,6 +6,8 @@ #include "memory.h" #include "system.h" +#include "zix/allocator.h" + #include <stddef.h> SerdStatus @@ -53,5 +55,5 @@ serd_block_dumper_flush(SerdBlockDumper* const dumper) void serd_block_dumper_close(SerdBlockDumper* const dumper) { - serd_aaligned_free(dumper->allocator, dumper->buf); + zix_aligned_free(dumper->allocator, dumper->buf); } diff --git a/src/block_dumper.h b/src/block_dumper.h index e5a2c318..038f0a82 100644 --- a/src/block_dumper.h +++ b/src/block_dumper.h @@ -4,17 +4,17 @@ #ifndef SERD_SRC_BLOCK_DUMPER_H #define SERD_SRC_BLOCK_DUMPER_H -#include "serd/memory.h" #include "serd/output_stream.h" #include "serd/status.h" #include "serd/world.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include <stddef.h> #include <string.h> typedef struct { - SerdAllocator* ZIX_NONNULL allocator; ///< Buffer allocator + ZixAllocator* ZIX_NONNULL allocator; ///< Buffer allocator SerdOutputStream* ZIX_ALLOCATED out; ///< Output stream to write to char* ZIX_ALLOCATED buf; ///< Local buffer if needed diff --git a/src/buffer.c b/src/buffer.c index c16a0ad6..64510d43 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,9 +1,8 @@ // Copyright 2011-2021 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "memory.h" - #include "serd/buffer.h" +#include "zix/allocator.h" #include <assert.h> #include <stddef.h> @@ -22,7 +21,7 @@ serd_buffer_write(const void* const buf, const size_t n_bytes = size * nmemb; char* const new_buf = - (char*)serd_arealloc(buffer->allocator, buffer->buf, buffer->len + n_bytes); + (char*)zix_realloc(buffer->allocator, buffer->buf, buffer->len + n_bytes); if (new_buf) { memcpy(new_buf + buffer->len, buf, n_bytes); diff --git a/src/byte_source.c b/src/byte_source.c index 249c0dde..6ec2084a 100644 --- a/src/byte_source.c +++ b/src/byte_source.c @@ -3,10 +3,10 @@ #include "byte_source.h" -#include "memory.h" #include "system.h" #include "serd/node.h" +#include "zix/allocator.h" #include <assert.h> #include <stdbool.h> @@ -39,11 +39,11 @@ serd_byte_source_page(SerdByteSource* const source) } static void -serd_byte_source_init_buffer(SerdAllocator* const allocator, +serd_byte_source_init_buffer(ZixAllocator* const allocator, SerdByteSource* const source) { if (source->block_size > 1) { - source->block = (uint8_t*)serd_aaligned_alloc( + source->block = (uint8_t*)zix_aligned_alloc( allocator, SERD_PAGE_SIZE, source->block_size); if ((source->read_buf = source->block)) { @@ -55,7 +55,7 @@ serd_byte_source_init_buffer(SerdAllocator* const allocator, } SerdByteSource* -serd_byte_source_new_input(SerdAllocator* const allocator, +serd_byte_source_new_input(ZixAllocator* const allocator, SerdInputStream* const input, const SerdNode* const name, const size_t block_size) @@ -73,7 +73,7 @@ serd_byte_source_new_input(SerdAllocator* const allocator, } SerdByteSource* source = - (SerdByteSource*)serd_acalloc(allocator, 1, sizeof(SerdByteSource)); + (SerdByteSource*)zix_calloc(allocator, 1, sizeof(SerdByteSource)); if (!source) { serd_node_free(allocator, source_name); @@ -91,7 +91,7 @@ serd_byte_source_new_input(SerdAllocator* const allocator, serd_byte_source_init_buffer(allocator, source); if (block_size > 1 && !source->block) { serd_node_free(allocator, source_name); - serd_afree(allocator, source); + zix_free(allocator, source); return NULL; } @@ -99,16 +99,16 @@ serd_byte_source_new_input(SerdAllocator* const allocator, } void -serd_byte_source_free(SerdAllocator* const allocator, +serd_byte_source_free(ZixAllocator* const allocator, SerdByteSource* const source) { if (source) { if (source->block_size > 1) { - serd_aaligned_free(allocator, source->block); + zix_aligned_free(allocator, source->block); } serd_node_free(allocator, source->name); - serd_afree(allocator, source); + zix_free(allocator, source); } } diff --git a/src/byte_source.h b/src/byte_source.h index ba63e794..ced36b82 100644 --- a/src/byte_source.h +++ b/src/byte_source.h @@ -8,9 +8,9 @@ #include "serd/caret.h" #include "serd/input_stream.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/status.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include <assert.h> @@ -33,13 +33,13 @@ typedef struct { } SerdByteSource; SerdByteSource* -serd_byte_source_new_input(SerdAllocator* allocator, +serd_byte_source_new_input(ZixAllocator* allocator, SerdInputStream* input, const SerdNode* name, size_t block_size); void -serd_byte_source_free(SerdAllocator* allocator, SerdByteSource* source); +serd_byte_source_free(ZixAllocator* allocator, SerdByteSource* source); SerdStatus serd_byte_source_prepare(SerdByteSource* source); diff --git a/src/canon.c b/src/canon.c index 2ef28e07..718b1a83 100644 --- a/src/canon.c +++ b/src/canon.c @@ -13,12 +13,12 @@ #include "serd/caret.h" #include "serd/event.h" #include "serd/log.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/sink.h" #include "serd/statement.h" #include "serd/status.h" #include "serd/world.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include "zix/string_view.h" @@ -34,7 +34,7 @@ typedef struct { } SerdCanonData; static ExessResult -build_typed(SerdAllocator* const ZIX_NONNULL allocator, +build_typed(ZixAllocator* const ZIX_NONNULL allocator, SerdNode** const out, const SerdNode* const ZIX_NONNULL node, const SerdNode* const ZIX_NONNULL datatype) @@ -91,7 +91,7 @@ build_typed(SerdAllocator* const ZIX_NONNULL allocator, } static ExessResult -build_tagged(SerdAllocator* const ZIX_NONNULL allocator, +build_tagged(ZixAllocator* const ZIX_NONNULL allocator, SerdNode** const out, const SerdNode* const ZIX_NONNULL node, const SerdNode* const ZIX_NONNULL language) @@ -129,7 +129,7 @@ serd_canon_on_statement(SerdCanonData* const data, const SerdStatementFlags flags, const SerdStatement* const statement) { - SerdAllocator* const allocator = serd_world_allocator(data->world); + ZixAllocator* const allocator = serd_world_allocator(data->world); const SerdNode* const object = serd_statement_object(statement); const SerdNode* const datatype = serd_node_datatype(object); const SerdNode* const language = serd_node_language(object); diff --git a/src/caret.c b/src/caret.c index 2d7e9a8e..e7ff58fa 100644 --- a/src/caret.c +++ b/src/caret.c @@ -3,10 +3,8 @@ #include "caret.h" -#include "memory.h" - #include "serd/caret.h" -#include "serd/memory.h" +#include "zix/allocator.h" #include <assert.h> #include <stdbool.h> @@ -14,15 +12,14 @@ #include <string.h> SerdCaret* -serd_caret_new(SerdAllocator* const allocator, +serd_caret_new(ZixAllocator* const allocator, const SerdNode* const document, const unsigned line, const unsigned column) { assert(document); - SerdCaret* const caret = - (SerdCaret*)serd_amalloc(allocator, sizeof(SerdCaret)); + SerdCaret* const caret = (SerdCaret*)zix_malloc(allocator, sizeof(SerdCaret)); if (caret) { caret->document = document; @@ -34,14 +31,13 @@ serd_caret_new(SerdAllocator* const allocator, } SerdCaret* -serd_caret_copy(SerdAllocator* const allocator, const SerdCaret* const caret) +serd_caret_copy(ZixAllocator* const allocator, const SerdCaret* const caret) { if (!caret) { return NULL; } - SerdCaret* const copy = - (SerdCaret*)serd_amalloc(allocator, sizeof(SerdCaret)); + SerdCaret* const copy = (SerdCaret*)zix_malloc(allocator, sizeof(SerdCaret)); if (copy) { memcpy(copy, caret, sizeof(SerdCaret)); @@ -51,9 +47,9 @@ serd_caret_copy(SerdAllocator* const allocator, const SerdCaret* const caret) } void -serd_caret_free(SerdAllocator* const allocator, SerdCaret* const caret) +serd_caret_free(ZixAllocator* const allocator, SerdCaret* const caret) { - serd_afree(allocator, caret); + zix_free(allocator, caret); } bool diff --git a/src/cursor.c b/src/cursor.c index d6a86d19..b3183ae9 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -3,14 +3,13 @@ #include "cursor.h" -#include "memory.h" #include "model.h" #include "node.h" #include "statement.h" #include "serd/log.h" -#include "serd/memory.h" #include "serd/statement.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include "zix/btree.h" #include "zix/status.h" @@ -122,14 +121,14 @@ serd_cursor_make(const SerdModel* const model, } SerdCursor* -serd_cursor_copy(SerdAllocator* const allocator, const SerdCursor* const cursor) +serd_cursor_copy(ZixAllocator* const allocator, const SerdCursor* const cursor) { if (!cursor) { return NULL; } SerdCursor* const copy = - (SerdCursor* const)serd_amalloc(allocator, sizeof(SerdCursor)); + (SerdCursor* const)zix_malloc(allocator, sizeof(SerdCursor)); if (copy) { memcpy(copy, cursor, sizeof(SerdCursor)); @@ -218,7 +217,7 @@ serd_cursor_equals(const SerdCursor* const lhs, const SerdCursor* const rhs) } void -serd_cursor_free(SerdAllocator* const allocator, SerdCursor* const cursor) +serd_cursor_free(ZixAllocator* const allocator, SerdCursor* const cursor) { - serd_afree(allocator, cursor); + zix_free(allocator, cursor); } diff --git a/src/describe.c b/src/describe.c index a7012cf9..41d5b67a 100644 --- a/src/describe.c +++ b/src/describe.c @@ -11,7 +11,6 @@ #include "serd/cursor.h" #include "serd/describe.h" -#include "serd/memory.h" #include "serd/model.h" #include "serd/node.h" #include "serd/sink.h" @@ -31,7 +30,7 @@ typedef enum { NAMED, ANON_S, ANON_O, LIST_S, LIST_O } NodeStyle; typedef struct { - SerdAllocator* allocator; // Allocator for auxiliary structures + ZixAllocator* allocator; // Allocator for auxiliary structures const SerdModel* model; // Model to read from const SerdSink* sink; // Sink to write description to ZixHash* list_subjects; // Nodes written in the current list or null @@ -286,7 +285,7 @@ write_range_statement(const DescribeContext* const ctx, } SerdStatus -serd_describe_range(SerdAllocator* const allocator, +serd_describe_range(ZixAllocator* const allocator, const SerdCursor* const range, const SerdSink* sink, const SerdDescribeFlags flags) @@ -300,7 +299,7 @@ serd_describe_range(SerdAllocator* const allocator, SerdCursor copy = *range; ZixHash* const list_subjects = - zix_hash_new((ZixAllocator*)allocator, identity, ptr_hash, ptr_equals); + zix_hash_new(allocator, identity, ptr_hash, ptr_equals); SerdStatus st = SERD_BAD_ALLOC; if (list_subjects) { @@ -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; diff --git a/src/filter.c b/src/filter.c index 581a7b72..dc6ef152 100644 --- a/src/filter.c +++ b/src/filter.c @@ -3,13 +3,12 @@ #include "serd/filter.h" +#include "sink.h" + #include "serd/event.h" -#include "serd/memory.h" #include "serd/statement.h" #include "serd/status.h" - -#include "memory.h" -#include "sink.h" +#include "zix/allocator.h" #include <assert.h> #include <stdbool.h> @@ -29,13 +28,13 @@ free_data(void* const handle) { if (handle) { SerdFilterData* const data = (SerdFilterData*)handle; - SerdAllocator* const allocator = data->target->allocator; + ZixAllocator* const allocator = data->target->allocator; serd_node_free(allocator, data->subject); serd_node_free(allocator, data->predicate); serd_node_free(allocator, data->object); serd_node_free(allocator, data->graph); - serd_afree(allocator, data); + zix_free(allocator, data); } } @@ -77,9 +76,9 @@ serd_filter_new(const SerdWorld* const world, assert(world); assert(target); - SerdAllocator* const allocator = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); SerdFilterData* const data = - (SerdFilterData*)serd_wcalloc(world, 1, sizeof(SerdFilterData)); + (SerdFilterData*)zix_calloc(alloc, 1, sizeof(SerdFilterData)); if (!data) { return NULL; @@ -89,35 +88,35 @@ serd_filter_new(const SerdWorld* const world, data->inclusive = inclusive; if (subject && serd_node_type(subject) != SERD_VARIABLE) { - if (!(data->subject = serd_node_copy(allocator, subject))) { + if (!(data->subject = serd_node_copy(alloc, subject))) { free_data(data); return NULL; } } if (predicate && serd_node_type(predicate) != SERD_VARIABLE) { - if (!(data->predicate = serd_node_copy(allocator, predicate))) { + if (!(data->predicate = serd_node_copy(alloc, predicate))) { free_data(data); return NULL; } } if (object && serd_node_type(object) != SERD_VARIABLE) { - if (!(data->object = serd_node_copy(allocator, object))) { + if (!(data->object = serd_node_copy(alloc, object))) { free_data(data); return NULL; } } if (graph && serd_node_type(graph) != SERD_VARIABLE) { - if (!(data->graph = serd_node_copy(allocator, graph))) { + if (!(data->graph = serd_node_copy(alloc, graph))) { free_data(data); return NULL; } } SerdSink* const sink = - serd_sink_new(allocator, data, serd_filter_on_event, free_data); + serd_sink_new(alloc, data, serd_filter_on_event, free_data); if (!sink) { free_data(data); diff --git a/src/memory.c b/src/memory.c deleted file mode 100644 index 74694c14..00000000 --- a/src/memory.c +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2011-2021 David Robillard <d@drobilla.net> -// SPDX-License-Identifier: ISC - -#include "memory.h" - -#include "serd/memory.h" -#include "zix/allocator.h" - -SerdAllocator* -serd_default_allocator(void) -{ - /* Note that SerdAllocator is intentionally the same as ZixAllocator. It - only exists to avoid exposing the zix API in the public serd API, which - I'm not sure would be appropriate. */ - - return (SerdAllocator*)zix_default_allocator(); -} diff --git a/src/memory.h b/src/memory.h index 80c60724..ace3abce 100644 --- a/src/memory.h +++ b/src/memory.h @@ -4,99 +4,18 @@ #ifndef SERD_SRC_MEMORY_H #define SERD_SRC_MEMORY_H -#include "serd/memory.h" #include "serd/world.h" +#include "zix/allocator.h" #include <stddef.h> #include <string.h> -// Allocator convenience wrappers that fall back to the default for NULL - -/// Convenience wrapper that defers to malloc() if allocator is null -static inline void* -serd_amalloc(SerdAllocator* const allocator, const size_t size) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - return actual->malloc(actual, size); -} - -/// Convenience wrapper that defers to calloc() if allocator is null -static inline void* -serd_acalloc(SerdAllocator* const allocator, - const size_t nmemb, - const size_t size) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - return actual->calloc(actual, nmemb, size); -} - -/// Convenience wrapper that defers to realloc() if allocator is null -static inline void* -serd_arealloc(SerdAllocator* const allocator, - void* const ptr, - const size_t size) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - return actual->realloc(actual, ptr, size); -} - -/// Convenience wrapper that defers to free() if allocator is null -static inline void -serd_afree(SerdAllocator* const allocator, void* const ptr) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - actual->free(actual, ptr); -} - -/// Convenience wrapper that defers to the system allocator if allocator is null -static inline void* -serd_aaligned_alloc(SerdAllocator* const allocator, - const size_t alignment, - const size_t size) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - return actual->aligned_alloc(actual, alignment, size); -} - -/// Convenience wrapper for serd_aaligned_alloc that zeros memory -static inline void* -serd_aaligned_calloc(SerdAllocator* const allocator, - const size_t alignment, - const size_t size) -{ - void* const ptr = serd_aaligned_alloc(allocator, alignment, size); - if (ptr) { - memset(ptr, 0, size); - } - return ptr; -} - -/// Convenience wrapper that defers to the system allocator if allocator is null -static inline void -serd_aaligned_free(SerdAllocator* const allocator, void* const ptr) -{ - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - actual->aligned_free(actual, ptr); -} - -// World convenience wrappers +// Allocator convenience wrappers that use the world allocator static inline void* serd_wmalloc(const SerdWorld* const world, const size_t size) { - return serd_amalloc(serd_world_allocator(world), size); + return zix_malloc(serd_world_allocator(world), size); } static inline void* @@ -104,19 +23,19 @@ serd_wcalloc(const SerdWorld* const world, const size_t nmemb, const size_t size) { - return serd_acalloc(serd_world_allocator(world), nmemb, size); + return zix_calloc(serd_world_allocator(world), nmemb, size); } static inline void* serd_wrealloc(const SerdWorld* const world, void* const ptr, const size_t size) { - return serd_arealloc(serd_world_allocator(world), ptr, size); + return zix_realloc(serd_world_allocator(world), ptr, size); } static inline void serd_wfree(const SerdWorld* const world, void* const ptr) { - serd_afree(serd_world_allocator(world), ptr); + zix_free(serd_world_allocator(world), ptr); } static inline void* @@ -124,13 +43,13 @@ serd_waligned_alloc(const SerdWorld* const world, const size_t alignment, const size_t size) { - return serd_aaligned_alloc(serd_world_allocator(world), alignment, size); + return zix_aligned_alloc(serd_world_allocator(world), alignment, size); } static inline void serd_waligned_free(const SerdWorld* const world, void* const ptr) { - serd_aaligned_free(serd_world_allocator(world), ptr); + zix_aligned_free(serd_world_allocator(world), ptr); } #endif // SERD_SRC_MEMORY_H diff --git a/src/model.c b/src/model.c index 89b37d83..fd1b0f92 100644 --- a/src/model.c +++ b/src/model.c @@ -77,8 +77,7 @@ serd_model_add_index(SerdModel* const model, const SerdStatementOrder order) const ZixBTreeCompareFunc comparator = serd_model_index_comparator(model, order); - model->indices[order] = - zix_btree_new((ZixAllocator*)model->allocator, comparator, ordering); + model->indices[order] = zix_btree_new(model->allocator, comparator, ordering); if (!model->indices[order]) { return SERD_BAD_ALLOC; @@ -117,7 +116,7 @@ serd_model_drop_index(SerdModel* const model, const SerdStatementOrder order) } static SerdModel* -serd_model_new_with_allocator(SerdAllocator* const allocator, +serd_model_new_with_allocator(ZixAllocator* const allocator, SerdWorld* const world, const SerdStatementOrder default_order, const SerdModelFlags flags) @@ -130,7 +129,7 @@ serd_model_new_with_allocator(SerdAllocator* const allocator, } SerdModel* model = - (SerdModel*)serd_acalloc(allocator, 1, sizeof(struct SerdModelImpl)); + (SerdModel*)zix_calloc(allocator, 1, sizeof(struct SerdModelImpl)); if (!model) { serd_nodes_free(nodes); @@ -220,7 +219,7 @@ make_begin_cursor(const SerdModel* const model, const SerdStatementOrder order) } SerdModel* -serd_model_copy(SerdAllocator* const allocator, const SerdModel* const model) +serd_model_copy(ZixAllocator* const allocator, const SerdModel* const model) { assert(model); @@ -280,7 +279,7 @@ serd_model_drop_statement(SerdModel* const model, } typedef struct { - SerdAllocator* allocator; + ZixAllocator* allocator; } DestroyContext; static void @@ -355,7 +354,7 @@ serd_model_empty(const SerdModel* const model) } SerdCursor* -serd_model_begin_ordered(SerdAllocator* const allocator, +serd_model_begin_ordered(ZixAllocator* const allocator, const SerdModel* const model, const SerdStatementOrder order) { @@ -367,7 +366,7 @@ serd_model_begin_ordered(SerdAllocator* const allocator, } SerdCursor* -serd_model_begin(SerdAllocator* const allocator, const SerdModel* const model) +serd_model_begin(ZixAllocator* const allocator, const SerdModel* const model) { assert(model); return serd_model_begin_ordered(allocator, model, model->default_order); @@ -551,7 +550,7 @@ serd_model_search(const SerdModel* const model, } SerdCursor* -serd_model_find(SerdAllocator* const allocator, +serd_model_find(ZixAllocator* const allocator, const SerdModel* const model, const SerdNode* const s, const SerdNode* const p, @@ -647,7 +646,7 @@ serd_model_intern_caret(SerdModel* const model, const SerdCaret* const caret) } SerdCaret* const copy = - (SerdCaret*)serd_acalloc(model->allocator, 1, sizeof(SerdCaret)); + (SerdCaret*)zix_calloc(model->allocator, 1, sizeof(SerdCaret)); if (copy) { copy->document = serd_nodes_intern(model->nodes, caret->document); diff --git a/src/model.h b/src/model.h index a67ba087..f0a54aaa 100644 --- a/src/model.h +++ b/src/model.h @@ -7,16 +7,16 @@ #include "cursor.h" #include "serd/cursor.h" -#include "serd/memory.h" #include "serd/model.h" #include "serd/nodes.h" #include "serd/world.h" +#include "zix/allocator.h" #include "zix/btree.h" #include <stddef.h> struct SerdModelImpl { - SerdAllocator* allocator; ///< Allocator for everything in this model + ZixAllocator* allocator; ///< Allocator for everything in this model SerdWorld* world; ///< World this model is a part of SerdNodes* nodes; ///< Interned nodes in this model ZixBTree* indices[12]; ///< Trees of SerdStatement pointers @@ -3,7 +3,6 @@ #include "node.h" -#include "memory.h" #include "namespaces.h" #include "string_utils.h" @@ -13,6 +12,7 @@ #include "serd/uri.h" #include "serd/value.h" #include "serd/write_result.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include "zix/string_view.h" @@ -180,17 +180,21 @@ serd_node_total_size(const SerdNode* const node) } SerdNode* -serd_node_malloc(SerdAllocator* const allocator, const size_t size) +serd_node_malloc(ZixAllocator* const allocator, const size_t size) { - SerdNode* const node = (SerdNode*)serd_aaligned_calloc( + SerdNode* const node = (SerdNode*)zix_aligned_alloc( allocator, serd_node_align, serd_node_pad_size(size)); + if (node) { + memset(node, 0, size); + } + assert((uintptr_t)node % serd_node_align == 0U); return node; } SerdNode* -serd_node_try_malloc(SerdAllocator* const allocator, const SerdWriteResult r) +serd_node_try_malloc(ZixAllocator* const allocator, const SerdWriteResult r) { return (r.status && r.status != SERD_OVERFLOW) ? NULL @@ -198,7 +202,7 @@ serd_node_try_malloc(SerdAllocator* const allocator, const SerdWriteResult r) } SerdStatus -serd_node_set(SerdAllocator* const allocator, +serd_node_set(ZixAllocator* const allocator, SerdNode** const dst, const SerdNode* const src) { @@ -207,9 +211,8 @@ serd_node_set(SerdAllocator* const allocator, const size_t size = serd_node_total_size(src); if (!*dst || serd_node_total_size(*dst) < size) { - serd_aaligned_free(allocator, *dst); - if (!(*dst = (SerdNode*)serd_aaligned_calloc( - allocator, serd_node_align, size))) { + zix_aligned_free(allocator, *dst); + if (!(*dst = serd_node_malloc(allocator, size))) { return SERD_BAD_ALLOC; } } @@ -599,7 +602,7 @@ serd_node_construct_uri(const size_t buf_size, } SerdNode* -serd_node_new(SerdAllocator* const allocator, const SerdNodeArgs args) +serd_node_new(ZixAllocator* const allocator, const SerdNodeArgs args) { SerdWriteResult r = serd_node_construct(0, NULL, args); if (r.status != SERD_OVERFLOW) { @@ -729,7 +732,7 @@ serd_node_decode(const SerdNode* const node, } SerdNode* -serd_node_copy(SerdAllocator* const allocator, const SerdNode* node) +serd_node_copy(ZixAllocator* const allocator, const SerdNode* node) { if (!node) { return NULL; @@ -737,7 +740,7 @@ serd_node_copy(SerdAllocator* const allocator, const SerdNode* node) const size_t size = serd_node_total_size(node); SerdNode* copy = - (SerdNode*)serd_aaligned_alloc(allocator, serd_node_align, size); + (SerdNode*)zix_aligned_alloc(allocator, serd_node_align, size); if (copy) { memcpy(copy, node, size); @@ -996,9 +999,9 @@ serd_node_flags(const SerdNode* const node) } void -serd_node_free(SerdAllocator* const allocator, SerdNode* const node) +serd_node_free(ZixAllocator* const allocator, SerdNode* const node) { - serd_aaligned_free(allocator, node); + zix_aligned_free(allocator, node); } #undef MUST_SUCCEED @@ -4,10 +4,10 @@ #ifndef SERD_SRC_NODE_H #define SERD_SRC_NODE_H -#include "serd/memory.h" #include "serd/node.h" #include "serd/status.h" #include "serd/write_result.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include <assert.h> @@ -87,14 +87,14 @@ serd_node_pattern_match(const SerdNode* ZIX_NULLABLE a, } ZIX_MALLOC_FUNC SerdNode* ZIX_ALLOCATED -serd_node_malloc(SerdAllocator* ZIX_NULLABLE allocator, size_t size); +serd_node_malloc(ZixAllocator* ZIX_NULLABLE allocator, size_t size); ZIX_MALLOC_FUNC SerdNode* ZIX_ALLOCATED -serd_node_try_malloc(SerdAllocator* ZIX_NULLABLE allocator, - SerdWriteResult result); +serd_node_try_malloc(ZixAllocator* ZIX_NULLABLE allocator, + SerdWriteResult result); SerdStatus -serd_node_set(SerdAllocator* ZIX_NULLABLE allocator, +serd_node_set(ZixAllocator* ZIX_NULLABLE allocator, SerdNode* ZIX_NONNULL* ZIX_NONNULL dst, const SerdNode* ZIX_NONNULL src); diff --git a/src/node_syntax.c b/src/node_syntax.c index a66c6e22..5fe0ae44 100644 --- a/src/node_syntax.c +++ b/src/node_syntax.c @@ -8,7 +8,6 @@ #include "serd/env.h" #include "serd/event.h" #include "serd/input_stream.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/node_syntax.h" #include "serd/output_stream.h" @@ -19,6 +18,7 @@ #include "serd/syntax.h" #include "serd/world.h" #include "serd/writer.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -26,8 +26,8 @@ #include <string.h> typedef struct { - SerdAllocator* allocator; - SerdNode* object; + ZixAllocator* allocator; + SerdNode* object; } NodeSyntaxContext; static SerdStatus @@ -54,7 +54,7 @@ serd_node_from_syntax_in(SerdWorld* const world, static const char* const prelude = "_:s <http://www.w3.org/2000/01/rdf-schema#object>"; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); const size_t str_len = strlen(str); const size_t doc_len = strlen(prelude) + str_len + 5; @@ -96,10 +96,10 @@ serd_node_from_syntax_in(SerdWorld* const world, } SerdNode* -serd_node_from_syntax(SerdAllocator* const allocator, - const char* const str, - const SerdSyntax syntax, - SerdEnv* const env) +serd_node_from_syntax(ZixAllocator* const allocator, + const char* const str, + const SerdSyntax syntax, + SerdEnv* const env) { assert(str); @@ -161,7 +161,7 @@ serd_node_to_syntax_in(SerdWorld* const world, } char* -serd_node_to_syntax(SerdAllocator* const allocator, +serd_node_to_syntax(ZixAllocator* const allocator, const SerdNode* const node, const SerdSyntax syntax, const SerdEnv* const env) diff --git a/src/nodes.c b/src/nodes.c index 22ee3146..e353b9aa 100644 --- a/src/nodes.c +++ b/src/nodes.c @@ -3,7 +3,6 @@ #include "nodes.h" -#include "memory.h" #include "node.h" #include "node_spec.h" @@ -12,7 +11,6 @@ #define ZIX_HASH_RECORD_TYPE NodesEntry #define ZIX_HASH_SEARCH_DATA_TYPE NodeSpec -#include "serd/memory.h" #include "serd/nodes.h" #include "serd/write_result.h" #include "zix/allocator.h" @@ -76,16 +74,16 @@ typedef struct { with an extra header) rather than node pointers directly. */ typedef struct { - SerdAllocator base; ///< Implementation of SerdAllocator (base "class") - SerdAllocator* real; ///< Underlying "real" memory allocator + ZixAllocator base; ///< Implementation of ZixAllocator (base "class") + ZixAllocator* real; ///< Underlying "real" memory allocator } SerdNodesEntryAllocator; ZIX_MALLOC_FUNC static void* -serd_nodes_entry_aligned_alloc(SerdAllocator* const allocator, - const size_t alignment, - const size_t size) +serd_nodes_entry_aligned_alloc(ZixAllocator* const allocator, + const size_t alignment, + const size_t size) { - SerdAllocator* const real = ((SerdNodesEntryAllocator*)allocator)->real; + ZixAllocator* const real = ((SerdNodesEntryAllocator*)allocator)->real; void* const ptr = real->aligned_alloc(real, alignment, serd_node_align + size); @@ -94,9 +92,9 @@ serd_nodes_entry_aligned_alloc(SerdAllocator* const allocator, } static void -serd_nodes_entry_aligned_free(SerdAllocator* const allocator, void* const ptr) +serd_nodes_entry_aligned_free(ZixAllocator* const allocator, void* const ptr) { - SerdAllocator* const real = ((SerdNodesEntryAllocator*)allocator)->real; + ZixAllocator* const real = ((SerdNodesEntryAllocator*)allocator)->real; if (ptr) { real->aligned_free(real, (((uint8_t*)ptr) - serd_node_align)); @@ -104,7 +102,7 @@ serd_nodes_entry_aligned_free(SerdAllocator* const allocator, void* const ptr) } static SerdNodesEntryAllocator -serd_nodes_entry_allocator(SerdAllocator* const real) +serd_nodes_entry_allocator(ZixAllocator* const real) { const SerdNodesEntryAllocator entry_allocator = { { @@ -115,7 +113,7 @@ serd_nodes_entry_allocator(SerdAllocator* const real) serd_nodes_entry_aligned_alloc, serd_nodes_entry_aligned_free, }, - real ? real : serd_default_allocator(), + real ? real : zix_default_allocator(), }; return entry_allocator; @@ -228,21 +226,21 @@ nodes_equal(const SerdNode* const a, const SerdNode* const b) static void free_entry(SerdNodes* const nodes, NodesEntry* const entry) { - serd_aaligned_free(&nodes->allocator.base, &entry->node); + zix_aligned_free(&nodes->allocator.base, &entry->node); } SerdNodes* -serd_nodes_new(SerdAllocator* const allocator) +serd_nodes_new(ZixAllocator* const allocator) { SerdNodes* const nodes = - (SerdNodes*)serd_acalloc(allocator, 1, sizeof(SerdNodes)); + (SerdNodes*)zix_calloc(allocator, 1, sizeof(SerdNodes)); if (nodes) { nodes->allocator = serd_nodes_entry_allocator(allocator); - if (!(nodes->hash = zix_hash_new( - (ZixAllocator*)allocator, nodes_key, nodes_hash, nodes_equal))) { - serd_afree(allocator, nodes); + if (!(nodes->hash = + zix_hash_new(allocator, nodes_key, nodes_hash, nodes_equal))) { + zix_free(allocator, nodes); return NULL; } } @@ -261,7 +259,7 @@ serd_nodes_free(SerdNodes* nodes) } zix_hash_free(nodes->hash); - serd_afree(nodes->allocator.real, nodes); + zix_free(nodes->allocator.real, nodes); } } @@ -399,8 +397,8 @@ serd_nodes_token(SerdNodes* const nodes, } // Otherwise, allocate and manage a new one - SerdAllocator* const alloc = &nodes->allocator.base; - SerdNode* const node = serd_node_new(alloc, serd_a_token(type, string)); + ZixAllocator* const alloc = &nodes->allocator.base; + SerdNode* const node = serd_node_new(alloc, serd_a_token(type, string)); return serd_nodes_manage_entry_node_at(nodes, node, plan); } @@ -428,8 +426,8 @@ serd_nodes_literal(SerdNodes* const nodes, } // Otherwise, allocate and manage a new one - SerdAllocator* const alloc = &nodes->allocator.base; - SerdNode* const node = + ZixAllocator* const alloc = &nodes->allocator.base; + SerdNode* const node = serd_node_new(alloc, serd_a_literal(string, flags, meta)); return serd_nodes_manage_entry_node_at(nodes, node, plan); diff --git a/src/reader.c b/src/reader.c index ce87a6f0..85db9b0b 100644 --- a/src/reader.c +++ b/src/reader.c @@ -305,7 +305,7 @@ serd_reader_free(SerdReader* const reader) serd_reader_finish(reader); } - serd_aaligned_free(reader->world->allocator, reader->stack.buf); + serd_stack_free(reader->world->allocator, &reader->stack); serd_wfree(reader->world, reader); } @@ -3,24 +3,24 @@ #include "sink.h" -#include "memory.h" #include "statement.h" #include "serd/node.h" #include "serd/sink.h" #include "serd/statement.h" #include "serd/status.h" +#include "zix/allocator.h" #include <assert.h> #include <stdlib.h> SerdSink* -serd_sink_new(SerdAllocator* const allocator, - void* const handle, - SerdEventFunc event_func, - SerdFreeFunc free_handle) +serd_sink_new(ZixAllocator* const allocator, + void* const handle, + SerdEventFunc event_func, + SerdFreeFunc free_handle) { - SerdSink* sink = (SerdSink*)serd_acalloc(allocator, 1, sizeof(SerdSink)); + SerdSink* sink = (SerdSink*)zix_calloc(allocator, 1, sizeof(SerdSink)); if (sink) { sink->allocator = allocator; @@ -40,7 +40,7 @@ serd_sink_free(SerdSink* sink) sink->free_handle(sink->handle); } - serd_afree(sink->allocator, sink); + zix_free(sink->allocator, sink); } } @@ -5,17 +5,17 @@ #define SERD_SRC_SINK_H #include "serd/event.h" -#include "serd/memory.h" #include "serd/sink.h" +#include "zix/allocator.h" /** An interface that receives a stream of RDF data. */ struct SerdSinkImpl { - SerdAllocator* allocator; - void* handle; - SerdFreeFunc free_handle; - SerdEventFunc on_event; + ZixAllocator* allocator; + void* handle; + SerdFreeFunc free_handle; + SerdEventFunc on_event; }; #endif // SERD_SRC_SINK_H diff --git a/src/stack.h b/src/stack.h index 40e8065d..94e091a1 100644 --- a/src/stack.h +++ b/src/stack.h @@ -19,21 +19,26 @@ typedef struct { } SerdStack; static inline SerdStack -serd_stack_new(SerdAllocator* const allocator, size_t size, size_t align) +serd_stack_new(ZixAllocator* const allocator, size_t size, size_t align) { const size_t aligned_size = (size + (align - 1)) / align * align; SerdStack stack; - stack.buf = (char*)serd_aaligned_calloc(allocator, align, aligned_size); + stack.buf = (char*)zix_aligned_alloc(allocator, align, aligned_size); stack.buf_size = size; stack.size = align; // 0 is reserved for null + + if (stack.buf) { + memset(stack.buf, 0, size); + } + return stack; } static inline void -serd_stack_free(SerdAllocator* const allocator, SerdStack* stack) +serd_stack_free(ZixAllocator* const allocator, SerdStack* stack) { - serd_aaligned_free(allocator, stack->buf); + zix_aligned_free(allocator, stack->buf); stack->buf = NULL; stack->buf_size = 0; stack->size = 0; diff --git a/src/statement.c b/src/statement.c index 5ea14910..45c10459 100644 --- a/src/statement.c +++ b/src/statement.c @@ -4,11 +4,10 @@ #include "statement.h" #include "caret.h" -#include "memory.h" #include "node.h" -#include "serd/memory.h" #include "serd/statement.h" +#include "zix/allocator.h" #include <assert.h> #include <stdbool.h> @@ -36,7 +35,7 @@ serd_statement_is_valid(const SerdNode* const subject, } SerdStatement* -serd_statement_new(SerdAllocator* const allocator, +serd_statement_new(ZixAllocator* const allocator, const SerdNode* const s, const SerdNode* const p, const SerdNode* const o, @@ -52,7 +51,7 @@ serd_statement_new(SerdAllocator* const allocator, } SerdStatement* statement = - (SerdStatement*)serd_amalloc(allocator, sizeof(SerdStatement)); + (SerdStatement*)zix_malloc(allocator, sizeof(SerdStatement)); if (statement) { statement->nodes[0] = s; @@ -63,7 +62,7 @@ serd_statement_new(SerdAllocator* const allocator, if (caret) { if (!(statement->caret = serd_caret_copy(allocator, caret))) { - serd_afree(allocator, statement); + zix_free(allocator, statement); return NULL; } } @@ -73,7 +72,7 @@ serd_statement_new(SerdAllocator* const allocator, } SerdStatement* -serd_statement_copy(SerdAllocator* const allocator, +serd_statement_copy(ZixAllocator* const allocator, const SerdStatement* const statement) { if (!statement) { @@ -81,15 +80,15 @@ serd_statement_copy(SerdAllocator* const allocator, } SerdStatement* copy = - (SerdStatement*)serd_amalloc(allocator, sizeof(SerdStatement)); + (SerdStatement*)zix_malloc(allocator, sizeof(SerdStatement)); if (copy) { memcpy(copy, statement, sizeof(SerdStatement)); if (statement->caret) { if (!(copy->caret = - (SerdCaret*)serd_amalloc(allocator, sizeof(SerdCaret)))) { - serd_afree(allocator, copy); + (SerdCaret*)zix_malloc(allocator, sizeof(SerdCaret)))) { + zix_free(allocator, copy); return NULL; } @@ -101,12 +100,12 @@ serd_statement_copy(SerdAllocator* const allocator, } void -serd_statement_free(SerdAllocator* const allocator, +serd_statement_free(ZixAllocator* const allocator, SerdStatement* const statement) { if (statement) { - serd_afree(allocator, statement->caret); - serd_afree(allocator, statement); + zix_free(allocator, statement->caret); + zix_free(allocator, statement); } } diff --git a/src/string.c b/src/string.c index ac964705..89c4abaa 100644 --- a/src/string.c +++ b/src/string.c @@ -1,21 +1,13 @@ // Copyright 2011-2021 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "memory.h" #include "string_utils.h" -#include "serd/memory.h" #include "serd/status.h" #include "serd/string.h" #include <stddef.h> -void -serd_free(SerdAllocator* const allocator, void* const ptr) -{ - serd_afree(allocator, ptr); -} - const char* serd_strerror(const SerdStatus status) { @@ -1,15 +1,14 @@ // Copyright 2011-2023 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "memory.h" #include "string_utils.h" #include "uri_utils.h" #include "serd/buffer.h" -#include "serd/memory.h" #include "serd/status.h" #include "serd/stream.h" #include "serd/uri.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -26,9 +25,9 @@ write_file_uri_char(const char c, void* const stream) } static char* -parse_hostname(SerdAllocator* const allocator, - const char* const authority, - char** const hostname) +parse_hostname(ZixAllocator* const allocator, + const char* const authority, + char** const hostname) { char* const path = strchr(authority, '/'); if (!path) { @@ -37,7 +36,7 @@ parse_hostname(SerdAllocator* const allocator, if (hostname) { const size_t len = (size_t)(path - authority); - if (!(*hostname = (char*)serd_acalloc(allocator, len + 1, 1))) { + if (!(*hostname = (char*)zix_calloc(allocator, len + 1, 1))) { return NULL; } @@ -48,9 +47,9 @@ parse_hostname(SerdAllocator* const allocator, } char* -serd_parse_file_uri(SerdAllocator* const allocator, - const char* const uri, - char** const hostname) +serd_parse_file_uri(ZixAllocator* const allocator, + const char* const uri, + char** const hostname) { assert(uri); @@ -95,7 +94,7 @@ serd_parse_file_uri(SerdAllocator* const allocator, } if (st || serd_buffer_close(&buffer)) { - serd_free(allocator, buffer.buf); + zix_free(allocator, buffer.buf); return NULL; } diff --git a/src/world.c b/src/world.c index b4fe4ebc..b160fc4e 100644 --- a/src/world.c +++ b/src/world.c @@ -4,13 +4,13 @@ #include "world.h" #include "log.h" -#include "memory.h" #include "namespaces.h" #include "node.h" #include "serd/node.h" #include "serd/status.h" #include "serd/world.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -18,19 +18,15 @@ #include <string.h> SerdWorld* -serd_world_new(SerdAllocator* const allocator) +serd_world_new(ZixAllocator* const allocator) { - SerdAllocator* const actual = - allocator ? allocator : serd_default_allocator(); - - SerdWorld* const world = - (SerdWorld*)serd_acalloc(actual, 1, sizeof(SerdWorld)); + ZixAllocator* const actual = allocator ? allocator : zix_default_allocator(); + SerdWorld* const world = (SerdWorld*)zix_calloc(actual, 1, sizeof(SerdWorld)); SerdNodes* const nodes = serd_nodes_new(actual); - if (!world || !nodes) { serd_nodes_free(nodes); - serd_afree(actual, world); + zix_free(actual, world); return NULL; } @@ -57,7 +53,7 @@ serd_world_new(SerdAllocator* const allocator) !(world->xsd_decimal = serd_nodes_get(nodes, serd_a_uri(xsd_decimal))) || !(world->xsd_integer = serd_nodes_get(nodes, serd_a_uri(xsd_integer)))) { serd_nodes_free(nodes); - serd_afree(actual, world); + zix_free(actual, world); return NULL; } @@ -72,7 +68,7 @@ serd_world_free(SerdWorld* const world) { if (world) { serd_nodes_free(world->nodes); - serd_afree(world->allocator, world); + zix_free(world->allocator, world); } } @@ -109,7 +105,7 @@ serd_world_get_blank(SerdWorld* const world) #undef BLANK_CHARS } -SerdAllocator* +ZixAllocator* serd_world_allocator(const SerdWorld* const world) { assert(world); diff --git a/src/world.h b/src/world.h index 8033dcec..67dd7916 100644 --- a/src/world.h +++ b/src/world.h @@ -7,15 +7,15 @@ #include "log.h" #include "node.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/world.h" +#include "zix/allocator.h" #include <stdint.h> struct SerdWorldImpl { - SerdAllocator* allocator; + ZixAllocator* allocator; SerdLog log; SerdLimits limits; SerdNodes* nodes; diff --git a/src/writer.c b/src/writer.c index b87df07a..fd52a123 100644 --- a/src/writer.c +++ b/src/writer.c @@ -19,8 +19,6 @@ #include "serd/env.h" #include "serd/event.h" #include "serd/log.h" -#include "serd/memory.h" -#include "serd/node.h" #include "serd/output_stream.h" #include "serd/sink.h" #include "serd/statement.h" @@ -28,6 +26,7 @@ #include "serd/syntax.h" #include "serd/uri.h" #include "serd/world.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -1406,7 +1405,7 @@ serd_writer_set_root_uri(SerdWriter* writer, const ZixStringView uri) { assert(writer); - SerdAllocator* const allocator = writer->world->allocator; + ZixAllocator* const allocator = writer->world->allocator; serd_node_free(allocator, writer->root_node); writer->root_node = NULL; |