ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_export_workspace.c File Reference

Manage the caller-owned media export bump workspace. More...

#include <string.h>
#include "mdl_export.h"
Include dependency graph for mdl_export_workspace.c:

Go to the source code of this file.

Functions

void mdl_export_workspace_init (mdl_export_workspace_t *ws, void *data, size_t cap)
 Bind an exporter arena without allocating memory.
void * mdl_export_workspace_take (mdl_export_workspace_t *ws, size_t bytes, size_t alignment)
 Reserve aligned bytes from an exporter arena.

Detailed Description

Manage the caller-owned media export bump workspace.

Keeps arena initialization and aligned reservation independent of the format dispatcher so readers and validators can reuse the workspace contract without linking every exporter.

[Ring 4 / Domain] {World: NS}

Definition in file mdl_export_workspace.c.

Function Documentation

◆ mdl_export_workspace_init()

void mdl_export_workspace_init ( mdl_export_workspace_t * ws,
void * data,
size_t cap )

Bind an exporter arena without allocating memory.

Initializes the caller-owned bump arena and clears usage counters; a NULL data pointer produces a zero-capacity workspace.

Parameters
[out]wsWorkspace descriptor to initialize, or NULL for no operation.
[in,out]dataCaller-owned writable arena bytes, or NULL.
[in]capNumber of bytes available at data.
Precondition
ws is NULL or points to writable descriptor storage.
Non-NULL data remains alive while the workspace is used.
Postcondition
A non-NULL workspace has zero used and high-water counters.
Capacity is cap only when data is non-NULL, otherwise zero.
Note
Thread-safe across distinct workspaces; one workspace is not shareable.
Since
0.1.0

Definition at line 19 of file mdl_export_workspace.c.

References mdl_export_workspace::cap, mdl_export_workspace::data, mdl_export_workspace::high_water, and mdl_export_workspace::used.

Referenced by internal_main_init().

◆ mdl_export_workspace_take()

void * mdl_export_workspace_take ( mdl_export_workspace_t * ws,
size_t bytes,
size_t alignment )

Reserve aligned bytes from an exporter arena.

Advances the caller-owned bump cursor only after overflow and capacity checks and records the largest successfully used offset.

Parameters
[in,out]wsInitialized exporter workspace.
[in]bytesNonzero number of bytes to reserve.
[in]alignmentNonzero power-of-two alignment.
Returns
Pointer to aligned caller-owned bytes, or NULL on invalid input/exhaustion.
Return values
non-NULLA complete aligned reservation was made.
NULLArguments were invalid or bounded capacity was exhausted.
Precondition
ws is non-NULL and was initialized by mdl_export_workspace_init.
alignment is a power of two.
Postcondition
Success advances used and may increase high_water.
Failure leaves all workspace counters unchanged.
Note
Thread-safe across distinct workspaces; one workspace is exclusive.
Since
0.1.0

Definition at line 30 of file mdl_export_workspace.c.

References mdl_export_workspace::cap, mdl_export_workspace::data, mdl_export_workspace::high_water, memcpy(), and mdl_export_workspace::used.

Referenced by internal_allocate_builder(), internal_allocate_container(), internal_allocate_pipeline(), internal_epub_carve_workspace(), internal_jof_carve_webp(), internal_jof_load_source(), internal_jof_produce_page(), internal_list_pages_open_dir(), internal_zip_workspace_alloc(), mdl_export_chapter_meta_ws(), priv_mdl_export_tar_gzip(), and priv_mdl_verify_rabook().