30typedef enum :
size_t {
41 "miniz workspace size must be a whole number of aligned cells");
43 "public miniz workspace must have exact advertised capacity");
62 uintptr_t address = 0U;
63 static_assert(
sizeof(address) ==
sizeof(pointer),
"uintptr_t must represent object pointers");
64 (void)
memcpy((
void*)&address, (
const void*)&pointer,
sizeof(address));
85 if (arena ==
nullptr) {
91 if (arena->
base ==
nullptr) {
109 void*
const cell = &arena->
base[off];
170 const uintptr_t end = base + (uintptr_t)arena->
capacity;
171 return (value >= first) && (value < end);
193 return (bytes + mask) & ~mask;
216 if ((size != 0U) && (items > (SIZE_MAX / size))) {
219 const size_t bytes = items * size;
245 if ((block->
size - need) < remainder_min) {
290 if ((arena ==
nullptr) || (workspace ==
nullptr)) {
300 .base = (uint8_t*)workspace,
313 if (arena !=
nullptr) {
360 if (address ==
nullptr) {
377 if (block->
size >= need) {
381 if (moved ==
nullptr) {
priv_alloc_const_t
Private allocator geometry and sentinel values.
@ k_priv_hdr_bytes
Aligned in-band header bytes.
@ k_priv_blk_used
Live-block marker.
@ k_priv_align
Maximum-alignment cell size.
@ k_priv_walk_max
Block-walk guard.
@ k_priv_blk_free
Free-block marker.
static bool internal_ready(const epub_miniz_arena_t *arena)
Validate an arena descriptor before using caller-owned storage.
void epub_miniz_free(void *opaque, void *address)
miniz-compatible free (mz_free_func).
ra8_err_t epub_miniz_arena_init(epub_miniz_arena_t *arena, void *workspace, size_t workspace_bytes)
Initialise or reset a miniz arena over caller-owned storage.
static size_t internal_align_up(size_t bytes)
Align a pool-bounded request upward to a complete arena cell.
static uint8_t * internal_end(const epub_miniz_arena_t *arena)
Return the arena's one-past byte sentinel.
static void internal_coalesce(const epub_miniz_arena_t *arena)
Merge all adjacent free blocks in an arena.
void * epub_miniz_alloc(void *opaque, size_t items, size_t size)
miniz-compatible allocator (mz_alloc_func).
static priv_blk_t * internal_cell_at(const epub_miniz_arena_t *arena, size_t off)
Cast byte offset off to an aligned block header.
void * epub_miniz_realloc(void *opaque, void *address, size_t items, size_t size)
miniz-compatible realloc (mz_realloc_func).
static void internal_split(const epub_miniz_arena_t *arena, priv_blk_t *block, size_t need)
Split a block if its remainder can hold another allocation.
static uintptr_t internal_pointer_address(const void *pointer)
Copy a pointer representation into an integer address.
static bool internal_request_bytes(size_t items, size_t size, size_t *out_bytes)
Validate and multiply a miniz count/size request exactly once.
static priv_blk_t * internal_next(const epub_miniz_arena_t *arena, priv_blk_t *block)
Return the block immediately following block.
void epub_miniz_arena_deinit(epub_miniz_arena_t *arena)
Invalidate an arena descriptor after miniz has released its blocks.
static bool internal_in_pool(const epub_miniz_arena_t *arena, const void *address)
Test whether an address lies in the payload-bearing arena range.
static priv_blk_t * internal_header(const epub_miniz_arena_t *arena, void *address)
Return the header for an allocation payload.
static uint8_t * internal_payload(priv_blk_t *block)
Return the payload immediately following block.
Caller-owned bounded-arena allocator for miniz.
@ k_epub_miniz_pool_bytes
Arena size, bytes (160 KiB).
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
Descriptor for one caller-owned miniz allocation arena.
size_t capacity
Usable bytes; exactly the documented pool size.
uint8_t initialized
1 after successful init; 0 after deinit.
uint8_t * base
Aligned caller workspace, or NULL when inactive.
Exactly-sized, maximally-aligned storage for one miniz arena.
Header prefixing every arena block.
size_t size
Aligned payload bytes after this header.
size_t is_free
One for free, zero for live.