Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
Writing and Copying

Bounded iterative traversal with preflighted allocation/capacity checks. More...

Functions

JSONBOURNE_API void * jsonbourne_val_write_opts (const jsonbourne_val *val, void *(*alc_fn)(void *, size_t), void(*free_fn)(void *, void *), void *alc_ctx, size_t *out_len)
 Validate a DOM and allocate minified JSON output.
JSONBOURNE_API void * jsonbourne_val_write (const jsonbourne_val *val, size_t *out_len)
 Allocate minified JSON using malloc.
JSONBOURNE_API void * jsonbourne_val_write_pretty_opts (const jsonbourne_val *val, const char *indent, const char *newline, void *(*alc_fn)(void *, size_t), void(*free_fn)(void *, void *), void *alc_ctx, size_t *out_len)
 Validate and allocate pretty output with explicit formatting/ownership.
JSONBOURNE_API void * jsonbourne_val_write_pretty (const jsonbourne_val *val, const char *indent, const char *newline, size_t *out_len)
 Allocate pretty JSON using malloc.
JSONBOURNE_API int jsonbourne_val_write_buf (const jsonbourne_val *val, char *buf, size_t cap, size_t *out_len)
 Preflight minified output, then write only if the caller buffer fits.
JSONBOURNE_API int jsonbourne_val_write_pretty_buf (const jsonbourne_val *val, const char *indent, const char *newline, char *buf, size_t cap, size_t *out_len)
 Preflight pretty output without allocating storage.
JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy_opts (const jsonbourne_val *val, void *(*alc_fn)(void *, size_t), void *alc_ctx)
 Deep-copy a validated value into one independent allocation.
JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy (const jsonbourne_val *val)
 Make an independently owned deep copy using malloc.

Detailed Description

Bounded iterative traversal with preflighted allocation/capacity checks.

Function Documentation

◆ jsonbourne_val_copy()

JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy ( const jsonbourne_val * val)

Make an independently owned deep copy using malloc.

Parameters
[in]valAccessible source root.
Returns
Copy released once with free(), or NULL on failure.
See also
jsonbourne_val_copy_opts()

Definition at line 1907 of file jsonbourne.c.

◆ jsonbourne_val_copy_opts()

JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy_opts ( const jsonbourne_val * val,
void *(* alc_fn )(void *, size_t),
void * alc_ctx )

Deep-copy a validated value into one independent allocation.

Parameters
[in]valAccessible source DOM; no source storage is borrowed by the copy.
[in]alc_fnOptional malloc-aligned allocator; NULL uses malloc.
[in]alc_ctxOpaque allocation context.
Returns
Owning copy, or NULL for invalid DOM, nesting/size limits or allocation.
Note
Source coordinates are deliberately not copied: they describe the original document, not the storage or provenance of the new tree. Custom allocators retain their own release policy, including rejected storage.

Definition at line 1870 of file jsonbourne.c.

◆ jsonbourne_val_write()

JSONBOURNE_API void * jsonbourne_val_write ( const jsonbourne_val * val,
size_t * out_len )

Allocate minified JSON using malloc.

Parameters
[in]valAccessible, stable DOM root.
[out]out_lenOptional NUL-inclusive output size; zero on failure.
Returns
Output released with free(), or NULL on failure.

Definition at line 1640 of file jsonbourne.c.

◆ jsonbourne_val_write_buf()

JSONBOURNE_API int jsonbourne_val_write_buf ( const jsonbourne_val * val,
char * buf,
size_t cap,
size_t * out_len )

Preflight minified output, then write only if the caller buffer fits.

Parameters
[in]valAccessible DOM disjoint from the output buffer.
[out]bufDestination; NULL measures without writing.
[in]capDestination capacity in bytes, including room for NUL.
[out]out_lenOptional required NUL-inclusive size; zero for an invalid DOM.
Return values
1Complete output, including NUL, was written.
0Validation failed or storage is absent/insufficient.
Note
A valid size probe returns 0 with the required length. Insufficient storage stays untouched because traversal is measured before the first write.

Preflight before writing; insufficient buffers are left untouched.

Definition at line 1690 of file jsonbourne.c.

◆ jsonbourne_val_write_opts()

JSONBOURNE_API void * jsonbourne_val_write_opts ( const jsonbourne_val * val,
void *(* alc_fn )(void *, size_t),
void(* free_fn )(void *, void *),
void * alc_ctx,
size_t * out_len )

Validate a DOM and allocate minified JSON output.

Parameters
[in]valAccessible root; must remain stable through both passes.
[in]alc_fnOptional output allocator; NULL uses malloc.
[in]free_fnOptional matching failure-release callback. If absent, failed output allocations are released with free().
[in]alc_ctxOpaque context passed to allocation/release callbacks.
[out]out_lenOptional output bytes INCLUDING NUL; zero on failure.
Returns
NUL-terminated output, or NULL for invalid DOM, limits or allocation.
Note
Successful output belongs to the caller and is never released here. Custom storage must be free-compatible unless free_fn supplies its release.

Definition at line 1635 of file jsonbourne.c.

◆ jsonbourne_val_write_pretty()

JSONBOURNE_API void * jsonbourne_val_write_pretty ( const jsonbourne_val * val,
const char * indent,
const char * newline,
size_t * out_len )

Allocate pretty JSON using malloc.

Parameters
[in]valAccessible, stable DOM root.
[in]indentJSON whitespace; NULL selects two spaces.
[in]newlineJSON whitespace; NULL selects LF.
[out]out_lenOptional NUL-inclusive size; zero on failure.
Returns
Output released with free(), or NULL on failure.

Definition at line 1651 of file jsonbourne.c.

◆ jsonbourne_val_write_pretty_buf()

JSONBOURNE_API int jsonbourne_val_write_pretty_buf ( const jsonbourne_val * val,
const char * indent,
const char * newline,
char * buf,
size_t cap,
size_t * out_len )

Preflight pretty output without allocating storage.

Parameters
[in]valAccessible DOM, stable and disjoint from buf.
[in]indentJSON whitespace; NULL selects two spaces.
[in]newlineJSON whitespace; NULL selects LF.
[out]bufOutput destination; NULL probes the required size.
[in]capDestination extent including terminator space.
[out]out_lenOptional required NUL-inclusive size; zero on validation failure.
Return values
1Complete pretty output was written.
0Invalid input/formatting or absent/insufficient storage.
See also
jsonbourne_val_write_buf() for size-probe and untouched-buffer behavior.

Definition at line 1694 of file jsonbourne.c.

◆ jsonbourne_val_write_pretty_opts()

JSONBOURNE_API void * jsonbourne_val_write_pretty_opts ( const jsonbourne_val * val,
const char * indent,
const char * newline,
void *(* alc_fn )(void *, size_t),
void(* free_fn )(void *, void *),
void * alc_ctx,
size_t * out_len )

Validate and allocate pretty output with explicit formatting/ownership.

Parameters
[in]valAccessible DOM root, stable throughout both passes.
[in]indentNUL-terminated JSON whitespace; NULL selects two spaces.
[in]newlineNUL-terminated JSON whitespace; NULL selects LF.
[in]alc_fnOptional output allocator; NULL uses malloc.
[in]free_fnOptional failure-release callback; NULL falls back to free().
[in]alc_ctxOpaque allocation/release context.
[out]out_lenOptional NUL-inclusive size; zero on failure.
Returns
Caller-owned output, or NULL on failure.
Note
Restricting formatting to JSON whitespace keeps pretty output valid JSON.
See also
jsonbourne_val_write_opts() for custom allocation release rules.

Definition at line 1644 of file jsonbourne.c.