diff options
author | David Robillard <d@drobilla.net> | 2022-12-19 17:55:02 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 0f9816d67bc67a396607291f845ca2a33c2285a7 (patch) | |
tree | b31fd1b344305dc984a2109084fa183573a0ae43 /test | |
parent | 258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d (diff) | |
download | serd-0f9816d67bc67a396607291f845ca2a33c2285a7.tar.gz serd-0f9816d67bc67a396607291f845ca2a33c2285a7.tar.bz2 serd-0f9816d67bc67a396607291f845ca2a33c2285a7.zip |
Use ZixAllocator directly
Diffstat (limited to 'test')
-rw-r--r-- | test/failing_allocator.c | 37 | ||||
-rw-r--r-- | test/failing_allocator.h | 8 | ||||
-rw-r--r-- | test/test_caret.c | 4 | ||||
-rw-r--r-- | test/test_free_null.c | 2 | ||||
-rw-r--r-- | test/test_model.c | 36 | ||||
-rw-r--r-- | test/test_node_syntax.c | 10 | ||||
-rw-r--r-- | test/test_nodes.c | 44 | ||||
-rw-r--r-- | test/test_overflow.c | 11 | ||||
-rw-r--r-- | test/test_reader_writer.c | 3 | ||||
-rw-r--r-- | test/test_statement.c | 18 | ||||
-rw-r--r-- | test/test_terse_write.c | 14 | ||||
-rw-r--r-- | test/test_uri.c | 20 | ||||
-rw-r--r-- | test/test_writer.c | 14 |
13 files changed, 110 insertions, 111 deletions
diff --git a/test/failing_allocator.c b/test/failing_allocator.c index 89c19bad..869cd15d 100644 --- a/test/failing_allocator.c +++ b/test/failing_allocator.c @@ -3,6 +3,7 @@ #include "failing_allocator.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include <stdbool.h> @@ -23,63 +24,63 @@ attempt(SerdFailingAllocator* const allocator) } ZIX_MALLOC_FUNC static void* -serd_failing_malloc(SerdAllocator* const allocator, const size_t size) +serd_failing_malloc(ZixAllocator* const allocator, const size_t size) { SerdFailingAllocator* const state = (SerdFailingAllocator*)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); return attempt(state) ? base->malloc(base, size) : NULL; } ZIX_MALLOC_FUNC static void* -serd_failing_calloc(SerdAllocator* const allocator, - const size_t nmemb, - const size_t size) +serd_failing_calloc(ZixAllocator* const allocator, + const size_t nmemb, + const size_t size) { SerdFailingAllocator* const state = (SerdFailingAllocator*)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); return attempt(state) ? base->calloc(base, nmemb, size) : NULL; } static void* -serd_failing_realloc(SerdAllocator* const allocator, - void* const ptr, - const size_t size) +serd_failing_realloc(ZixAllocator* const allocator, + void* const ptr, + const size_t size) { SerdFailingAllocator* const state = (SerdFailingAllocator*)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); return attempt(state) ? base->realloc(base, ptr, size) : NULL; } static void -serd_failing_free(SerdAllocator* const allocator, void* const ptr) +serd_failing_free(ZixAllocator* const allocator, void* const ptr) { (void)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); base->free(base, ptr); } ZIX_MALLOC_FUNC static void* -serd_failing_aligned_alloc(SerdAllocator* const allocator, - const size_t alignment, - const size_t size) +serd_failing_aligned_alloc(ZixAllocator* const allocator, + const size_t alignment, + const size_t size) { SerdFailingAllocator* const state = (SerdFailingAllocator*)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); return attempt(state) ? base->aligned_alloc(base, alignment, size) : NULL; } static void -serd_failing_aligned_free(SerdAllocator* const allocator, void* const ptr) +serd_failing_aligned_free(ZixAllocator* const allocator, void* const ptr) { (void)allocator; - SerdAllocator* const base = serd_default_allocator(); + ZixAllocator* const base = zix_default_allocator(); base->aligned_free(base, ptr); } diff --git a/test/failing_allocator.h b/test/failing_allocator.h index 7bc514bb..16ed0bec 100644 --- a/test/failing_allocator.h +++ b/test/failing_allocator.h @@ -4,15 +4,15 @@ #ifndef SERD_TEST_FAILING_ALLOCATOR_H #define SERD_TEST_FAILING_ALLOCATOR_H -#include "serd/serd.h" +#include "zix/allocator.h" #include <stddef.h> /// An allocator that fails after some number of successes for testing typedef struct { - SerdAllocator base; ///< Base allocator instance - size_t n_allocations; ///< Number of attempted allocations - size_t n_remaining; ///< Number of remaining successful allocations + ZixAllocator base; ///< Base allocator instance + size_t n_allocations; ///< Number of attempted allocations + size_t n_remaining; ///< Number of remaining successful allocations } SerdFailingAllocator; SerdFailingAllocator diff --git a/test/test_caret.c b/test/test_caret.c index 379f80eb..98b1af67 100644 --- a/test/test_caret.c +++ b/test/test_caret.c @@ -6,9 +6,9 @@ #include "failing_allocator.h" #include "serd/caret.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" +#include "zix/allocator.h" #include <assert.h> #include <stddef.h> @@ -17,7 +17,7 @@ static int test_caret(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = serd_nodes_get(nodes, serd_a_string("node")); diff --git a/test/test_free_null.c b/test/test_free_null.c index 89846c7f..c9f76c2c 100644 --- a/test/test_free_null.c +++ b/test/test_free_null.c @@ -6,7 +6,6 @@ #include "serd/caret.h" #include "serd/cursor.h" #include "serd/env.h" -#include "serd/memory.h" #include "serd/model.h" #include "serd/node.h" #include "serd/nodes.h" @@ -21,7 +20,6 @@ int main(void) { - serd_free(NULL, NULL); serd_node_free(NULL, NULL); serd_world_free(NULL); serd_env_free(NULL); diff --git a/test/test_model.c b/test/test_model.c index 2e3a7847..f1a8d5cb 100644 --- a/test/test_model.c +++ b/test/test_model.c @@ -12,7 +12,6 @@ #include "serd/env.h" #include "serd/inserter.h" #include "serd/log.h" -#include "serd/memory.h" #include "serd/model.h" #include "serd/node.h" #include "serd/nodes.h" @@ -23,6 +22,7 @@ #include "serd/syntax.h" #include "serd/world.h" #include "serd/writer.h" +#include "zix/allocator.h" #include "zix/attributes.h" #include "zix/string_view.h" @@ -156,8 +156,8 @@ test_read(SerdWorld* world, const SerdNode* g, const unsigned n_quads) { - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* const nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* const nodes = serd_nodes_new(allocator); SerdCursor* cursor = serd_model_begin(NULL, model); const SerdStatement* prev = NULL; @@ -604,10 +604,10 @@ test_inserter(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* const nodes = serd_nodes_new(allocator); - SerdModel* const model = serd_model_new(world, SERD_ORDER_SPO, 0U); - SerdSink* const inserter = serd_inserter_new(model, NULL); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* const nodes = serd_nodes_new(allocator); + SerdModel* const model = serd_model_new(world, SERD_ORDER_SPO, 0U); + SerdSink* const inserter = serd_inserter_new(model, NULL); const SerdNode* const s = serd_nodes_get(nodes, serd_a_uri_string("http://example.org/s")); @@ -673,7 +673,7 @@ test_add_erase(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); SerdModel* const model = serd_model_new(world, SERD_ORDER_SPO, 0U); @@ -713,8 +713,8 @@ test_add_bad_statement(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const allocator = serd_world_allocator(world); - SerdNodes* const nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = serd_world_allocator(world); + SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* s = serd_nodes_get(nodes, serd_a_uri_string("urn:s")); const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p")); @@ -1089,7 +1089,7 @@ test_write_flat_range(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); SerdModel* model = serd_model_new(world, SERD_ORDER_SPO, SERD_STORE_GRAPHS); SerdNodes* nodes = serd_nodes_new(alloc); @@ -1136,7 +1136,7 @@ test_write_flat_range(SerdWorld* world, const unsigned n_quads) assert(str); assert(!strcmp(str, expected)); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_writer_free(writer); serd_model_free(model); serd_env_free(env); @@ -1149,7 +1149,7 @@ test_write_bad_list(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); SerdModel* model = serd_model_new(world, SERD_ORDER_SPO, SERD_STORE_GRAPHS); SerdNodes* nodes = serd_nodes_new(alloc); @@ -1212,7 +1212,7 @@ test_write_bad_list(SerdWorld* world, const unsigned n_quads) assert(str); assert(!strcmp(str, expected)); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_writer_free(writer); serd_close_output(&out); serd_model_free(model); @@ -1226,7 +1226,7 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); SerdModel* model = serd_model_new(world, SERD_ORDER_SPO, SERD_STORE_GRAPHS); SerdNodes* nodes = serd_nodes_new(alloc); @@ -1284,7 +1284,7 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads) assert(str); assert(!strcmp(str, expected)); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_writer_free(writer); serd_close_output(&out); serd_model_free(model); @@ -1317,7 +1317,7 @@ test_write_error_in_list_subject(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); serd_set_log_func(world, expected_error, NULL); @@ -1377,7 +1377,7 @@ test_write_error_in_list_object(SerdWorld* world, const unsigned n_quads) { (void)n_quads; - SerdAllocator* const alloc = serd_world_allocator(world); + ZixAllocator* const alloc = serd_world_allocator(world); serd_set_log_func(world, expected_error, NULL); diff --git a/test/test_node_syntax.c b/test/test_node_syntax.c index 5e106a94..ce556669 100644 --- a/test/test_node_syntax.c +++ b/test/test_node_syntax.c @@ -6,12 +6,12 @@ #include "failing_allocator.h" #include "serd/env.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/node_syntax.h" #include "serd/nodes.h" #include "serd/syntax.h" #include "serd/value.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -50,11 +50,11 @@ test_failed_alloc(void) assert(!s || !c); serd_node_free(&allocator.base, c); - serd_free(&allocator.base, s); + zix_free(&allocator.base, s); } serd_node_free(&allocator.base, copy); - serd_free(&allocator.base, str); + zix_free(&allocator.base, str); serd_node_free(&allocator.base, node); } @@ -72,7 +72,7 @@ check(const SerdSyntax syntax, const bool success = !strcmp(str, expected) && serd_node_equals(copy, node); serd_node_free(NULL, copy); - serd_free(NULL, str); + zix_free(NULL, str); serd_env_free(env); return success; } @@ -162,7 +162,7 @@ test_ntriples(void) serd_node_free(NULL, copy); serd_env_free(env); - serd_free(NULL, str); + zix_free(NULL, str); } assert(check(SERD_NTRIPLES, diff --git a/test/test_nodes.c b/test/test_nodes.c index b220f6d7..974ee062 100644 --- a/test/test_nodes.c +++ b/test/test_nodes.c @@ -5,11 +5,11 @@ #include "failing_allocator.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/uri.h" #include "serd/value.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -75,7 +75,7 @@ test_intern_failed_alloc(void) static void test_intern(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* nodes = serd_nodes_new(allocator); SerdNode* node = serd_node_new(NULL, serd_a_string("node")); @@ -101,7 +101,7 @@ test_string(void) { static const ZixStringView string = ZIX_STATIC_STRING("string"); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = @@ -133,7 +133,7 @@ test_string(void) static void test_invalid_literal(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -161,7 +161,7 @@ test_plain_literal(void) static const ZixStringView string = ZIX_STATIC_STRING("string"); static const ZixStringView language = ZIX_STATIC_STRING("en"); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = @@ -214,7 +214,7 @@ test_typed_literal(void) static const ZixStringView string = ZIX_STATIC_STRING("string"); static const ZixStringView datatype = ZIX_STATIC_STRING(NS_EG "Type"); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = @@ -246,7 +246,7 @@ test_typed_literal(void) static void test_boolean(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -285,8 +285,8 @@ test_boolean(void) static void test_decimal(void) { - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* const nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const a = serd_nodes_get(nodes, serd_a_decimal(-12.3456789)); const SerdNode* const b = serd_nodes_get(nodes, serd_a_decimal(-12.3456789)); @@ -306,7 +306,7 @@ test_decimal(void) static void test_double(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -327,7 +327,7 @@ test_double(void) static void test_float(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -348,8 +348,8 @@ test_float(void) static void test_integer(void) { - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* const nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const a = serd_nodes_get(nodes, serd_a_integer(-1234567890)); const SerdNode* const b = serd_nodes_get(nodes, serd_a_integer(-1234567890)); @@ -371,7 +371,7 @@ test_base64(void) { static const char data[] = {'f', 'o', 'o', 'b', 'a', 'r'}; - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -398,8 +398,8 @@ test_uri(void) { static const ZixStringView string = ZIX_STATIC_STRING("http://example.org/"); - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* const nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = serd_nodes_get(nodes, serd_a_uri(string)); @@ -419,7 +419,7 @@ test_parsed_uri(void) { static const ZixStringView string = ZIX_STATIC_STRING("http://example.org/"); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdURIView uri = serd_parse_uri(string.data); @@ -448,7 +448,7 @@ test_parsed_uri(void) static void test_file_uri(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); static const ZixStringView local_string = ZIX_STATIC_STRING("file:///d/f.txt"); @@ -497,7 +497,7 @@ test_blank(void) { static const ZixStringView string = ZIX_STATIC_STRING("b42"); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); const SerdNode* const node = serd_nodes_get(nodes, serd_a_blank(string)); @@ -516,8 +516,8 @@ test_blank(void) static void test_deref(void) { - SerdAllocator* const allocator = serd_default_allocator(); - SerdNodes* nodes = serd_nodes_new(allocator); + ZixAllocator* const allocator = zix_default_allocator(); + SerdNodes* nodes = serd_nodes_new(allocator); const SerdNode* original = serd_nodes_get(nodes, serd_a_string("node")); const SerdNode* another = serd_nodes_get(nodes, serd_a_string("node")); @@ -558,7 +558,7 @@ test_deref(void) static void test_get(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* nodes = serd_nodes_new(allocator); SerdNode* node = serd_node_new(NULL, serd_a_string("node")); diff --git a/test/test_overflow.c b/test/test_overflow.c index f2ff184b..39fbd00d 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -4,6 +4,7 @@ #undef NDEBUG #include "serd/serd.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -23,11 +24,11 @@ test_size(SerdWorld* const world, limits.reader_stack_size = stack_size; serd_world_set_limits(world, limits); - SerdNodes* const nodes = serd_world_nodes(world); - SerdAllocator* const alloc = serd_world_allocator(world); - SerdSink* const sink = serd_sink_new(alloc, NULL, NULL, NULL); - SerdEnv* const env = serd_env_new(alloc, zix_empty_string()); - SerdReader* const reader = serd_reader_new(world, syntax, flags, env, sink); + SerdNodes* const nodes = serd_world_nodes(world); + ZixAllocator* const alloc = serd_world_allocator(world); + SerdSink* const sink = serd_sink_new(alloc, NULL, NULL, NULL); + SerdEnv* const env = serd_env_new(alloc, zix_empty_string()); + SerdReader* const reader = serd_reader_new(world, syntax, flags, env, sink); if (!reader) { return SERD_BAD_STACK; } diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 1858d570..0237cb6c 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -7,7 +7,6 @@ #include "serd/env.h" #include "serd/event.h" #include "serd/input_stream.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/output_stream.h" @@ -233,7 +232,7 @@ test_writer(const char* const path) char* const out = (char*)buffer.buf; assert(out); assert(!strcmp(out, "@base <http://example.org/base> .\n")); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_env_free(env); serd_world_free(world); diff --git a/test/test_statement.c b/test/test_statement.c index e960002f..3cad95bb 100644 --- a/test/test_statement.c +++ b/test/test_statement.c @@ -6,10 +6,10 @@ #include "failing_allocator.h" #include "serd/caret.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/statement.h" +#include "zix/allocator.h" #include <assert.h> #include <stddef.h> @@ -20,7 +20,7 @@ static void test_new(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); assert(!serd_statement_copy(allocator, NULL)); @@ -49,7 +49,7 @@ test_copy(void) { assert(!serd_statement_copy(NULL, NULL)); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); assert(!serd_statement_copy(allocator, NULL)); @@ -80,7 +80,7 @@ test_copy_with_caret(void) { assert(!serd_statement_copy(NULL, NULL)); - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); assert(!serd_statement_copy(allocator, NULL)); @@ -115,14 +115,14 @@ test_copy_with_caret(void) static void test_free(void) { - serd_statement_free(serd_default_allocator(), NULL); + serd_statement_free(zix_default_allocator(), NULL); serd_statement_free(NULL, NULL); } static void test_fields(void) { - SerdAllocator* const allocator = serd_default_allocator(); + ZixAllocator* const allocator = zix_default_allocator(); SerdNodes* const nodes = serd_nodes_new(allocator); @@ -194,7 +194,7 @@ test_fields(void) static void test_failed_alloc(void) { - SerdNodes* const nodes = serd_nodes_new(serd_default_allocator()); + SerdNodes* const nodes = serd_nodes_new(zix_default_allocator()); const SerdNode* const f = serd_nodes_get(nodes, serd_a_string("file")); const SerdNode* const s = serd_nodes_get(nodes, serd_a_uri_string(NS_EG "s")); @@ -202,7 +202,7 @@ test_failed_alloc(void) const SerdNode* const o = serd_nodes_get(nodes, serd_a_uri_string(NS_EG "o")); const SerdNode* const g = serd_nodes_get(nodes, serd_a_uri_string(NS_EG "g")); - SerdCaret* const caret = serd_caret_new(serd_default_allocator(), f, 1, 1); + SerdCaret* const caret = serd_caret_new(zix_default_allocator(), f, 1, 1); SerdFailingAllocator allocator = serd_failing_allocator(); @@ -233,7 +233,7 @@ test_failed_alloc(void) serd_statement_free(&allocator.base, copy); serd_statement_free(&allocator.base, statement); - serd_caret_free(serd_default_allocator(), caret); + serd_caret_free(zix_default_allocator(), caret); serd_nodes_free(nodes); } diff --git a/test/test_terse_write.c b/test/test_terse_write.c index 0c55eb9d..c6a14d7d 100644 --- a/test/test_terse_write.c +++ b/test/test_terse_write.c @@ -5,7 +5,6 @@ #include "serd/buffer.h" #include "serd/env.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/output_stream.h" @@ -14,6 +13,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> @@ -40,11 +40,11 @@ check_output(SerdWriter* writer, SerdBuffer* buffer, const char* expected) static int test(void) { - SerdWorld* world = serd_world_new(NULL); - SerdAllocator* alloc = serd_world_allocator(world); - SerdBuffer buffer = {NULL, NULL, 0}; - SerdEnv* env = serd_env_new(alloc, zix_empty_string()); - SerdNodes* nodes = serd_nodes_new(alloc); + SerdWorld* world = serd_world_new(NULL); + ZixAllocator* alloc = serd_world_allocator(world); + SerdBuffer buffer = {NULL, NULL, 0}; + SerdEnv* env = serd_env_new(alloc, zix_empty_string()); + SerdNodes* nodes = serd_nodes_new(alloc); const SerdNode* b1 = serd_nodes_get(nodes, serd_a_blank_string("b1")); const SerdNode* l1 = serd_nodes_get(nodes, serd_a_blank_string("l1")); @@ -102,7 +102,7 @@ test(void) serd_writer_free(writer); serd_close_output(&output); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_nodes_free(nodes); serd_env_free(env); serd_world_free(world); diff --git a/test/test_uri.c b/test/test_uri.c index bf4fa0f3..9c832bc1 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -5,10 +5,10 @@ #include "failing_allocator.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/uri.h" +#include "zix/allocator.h" #include "zix/string_view.h" #include <assert.h> @@ -29,8 +29,8 @@ test_file_uri_failed_alloc(void) assert(!strcmp(path, "/path/spacey dir/100%.ttl")); assert(!strcmp(hostname, "host")); - serd_free(&allocator.base, path); - serd_free(&allocator.base, hostname); + zix_free(&allocator.base, path); + zix_free(&allocator.base, hostname); // Test that each allocation failing is handled gracefully const size_t n_allocs = allocator.n_allocations; @@ -40,8 +40,8 @@ test_file_uri_failed_alloc(void) path = serd_parse_file_uri(&allocator.base, string, &hostname); assert(!path || !hostname); - serd_free(&allocator.base, path); - serd_free(&allocator.base, hostname); + zix_free(&allocator.base, path); + zix_free(&allocator.base, hostname); } } @@ -90,8 +90,8 @@ test_file_uri(const char* const hostname, assert(!hostname || !strcmp(hostname, out_hostname)); assert(!strcmp(out_path, expected_path)); - serd_free(NULL, out_path); - serd_free(NULL, out_hostname); + zix_free(NULL, out_path); + zix_free(NULL, out_hostname); serd_nodes_free(nodes); } @@ -148,17 +148,17 @@ test_uri_parsing(void) // Check that NULL hostname doesn't crash char* out_path = serd_parse_file_uri(NULL, "file://me/path", NULL); assert(!strcmp(out_path, "/path")); - serd_free(NULL, out_path); + zix_free(NULL, out_path); // Invalid first escape character out_path = serd_parse_file_uri(NULL, "file:///foo/%0Xbar", NULL); assert(!strcmp(out_path, "/foo/bar")); - serd_free(NULL, out_path); + zix_free(NULL, out_path); // Invalid second escape character out_path = serd_parse_file_uri(NULL, "file:///foo/%X0bar", NULL); assert(!strcmp(out_path, "/foo/bar")); - serd_free(NULL, out_path); + zix_free(NULL, out_path); } static void diff --git a/test/test_writer.c b/test/test_writer.c index 17790527..fce67f8f 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -8,7 +8,6 @@ #include "serd/buffer.h" #include "serd/env.h" #include "serd/event.h" -#include "serd/memory.h" #include "serd/node.h" #include "serd/nodes.h" #include "serd/output_stream.h" @@ -18,6 +17,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> @@ -126,7 +126,7 @@ test_write_failed_alloc(void) serd_close_output(&output); serd_env_free(env); serd_buffer_close(&buffer); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_world_free(world); } @@ -152,7 +152,7 @@ test_write_bad_event(void) char* const out = (char*)buffer.buf; assert(out); assert(!strcmp(out, "")); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_writer_free(writer); serd_env_free(env); @@ -199,7 +199,7 @@ test_write_long_literal(void) "\t<http://example.org/p> \"\"\"hello \"\"\\\"world\"\"\\\"!\"\"\" .\n"; assert(!strcmp(out, expected)); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_world_free(world); } @@ -429,7 +429,7 @@ test_write_empty_syntax(void) char* const out = (char*)buffer.buf; assert(out); assert(strlen(out) == 0); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_writer_free(writer); serd_close_output(&output); @@ -477,7 +477,7 @@ check_pname_escape(const char* const lname, const char* const expected) char* const out = (char*)buffer.buf; assert(!strcmp(out, expected)); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_world_free(world); } @@ -543,7 +543,7 @@ test_write_bad_uri(void) serd_writer_free(writer); serd_close_output(&output); - serd_free(NULL, buffer.buf); + zix_free(NULL, buffer.buf); serd_env_free(env); serd_world_free(world); } |