From 248a874d7425749d29cf900a1c3783c624ea8d8c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 10 Sep 2023 15:06:42 -0400 Subject: Add support for custom allocators This makes it explicit in the API where memory is allocated, and allows the user to provide a custom allocator to avoid the use of the default system allocator for whatever reason. --- src/block_dumper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/block_dumper.c') diff --git a/src/block_dumper.c b/src/block_dumper.c index 174f0215..21a10fcc 100644 --- a/src/block_dumper.c +++ b/src/block_dumper.c @@ -2,12 +2,15 @@ // SPDX-License-Identifier: ISC #include "block_dumper.h" + +#include "memory.h" #include "system.h" #include SerdStatus -serd_block_dumper_open(SerdBlockDumper* const dumper, +serd_block_dumper_open(const SerdWorld* const world, + SerdBlockDumper* const dumper, SerdOutputStream* const output, const size_t block_size) { @@ -24,7 +27,7 @@ serd_block_dumper_open(SerdBlockDumper* const dumper, return SERD_SUCCESS; } - dumper->buf = (char*)serd_allocate_buffer(block_size); + dumper->buf = (char*)serd_waligned_alloc(world, SERD_PAGE_SIZE, block_size); return dumper->buf ? SERD_SUCCESS : SERD_BAD_ALLOC; } @@ -50,5 +53,5 @@ serd_block_dumper_flush(SerdBlockDumper* const dumper) void serd_block_dumper_close(SerdBlockDumper* const dumper) { - serd_free_aligned(dumper->buf); + serd_aaligned_free(dumper->allocator, dumper->buf); } -- cgit v1.2.1