aboutsummaryrefslogtreecommitdiffstats
path: root/src/block_dumper.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-09-10 15:06:42 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit248a874d7425749d29cf900a1c3783c624ea8d8c (patch)
treeaed59f5a484a815cd254506866e98a947858904d /src/block_dumper.c
parent0bd10132c6707353dba80bd89cf0102ee7ca4e34 (diff)
downloadserd-248a874d7425749d29cf900a1c3783c624ea8d8c.tar.gz
serd-248a874d7425749d29cf900a1c3783c624ea8d8c.tar.bz2
serd-248a874d7425749d29cf900a1c3783c624ea8d8c.zip
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.
Diffstat (limited to 'src/block_dumper.c')
-rw-r--r--src/block_dumper.c9
1 files changed, 6 insertions, 3 deletions
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 <stddef.h>
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);
}