Strict/relaxed reads, allocation-free checks and caller-owned storage. More...
Functions | |
| JSONBOURNE_API struct jsonbourne_read_limits | jsonbourne_read_limits_default (void) |
| Create default budgets using the linked implementation's reader limit. | |
| JSONBOURNE_API int | jsonbourne_read_measure (const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, size_t *required, jsonbourne_read_err *err) |
| Validate input and measure the exact single-allocation DOM size. | |
| JSONBOURNE_API int | jsonbourne_read_validate (const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, jsonbourne_read_err *err) |
| Validate the entire extent without allocating a DOM or changing input. | |
| JSONBOURNE_API jsonbourne_val * | jsonbourne_read_buf (const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, void *buf, size_t cap, size_t *required, jsonbourne_read_err *err) |
| Read a DOM into aligned caller storage without heap allocation. | |
| JSONBOURNE_API jsonbourne_val * | jsonbourne_read_opts_with_limits (const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, void *(*alc_fn)(void *, size_t), void *alc_ctx, jsonbourne_read_err *err) |
| Validate against explicit budgets, then allocate the entire DOM once. | |
| JSONBOURNE_API jsonbourne_val * | jsonbourne_read_opts (const void *src, size_t len, jsonbourne_read_flag flg, void *(*alc_fn)(void *, size_t), void *alc_ctx, jsonbourne_read_err *err) |
| Read with named options and the linked implementation's default limits. | |
| JSONBOURNE_API jsonbourne_val * | jsonbourne_read (const void *src, size_t len) |
| Read strict JSON with default limits and malloc-backed ownership. | |
Detailed Description
Strict/relaxed reads, allocation-free checks and caller-owned storage.
Function Documentation
◆ jsonbourne_read()
| JSONBOURNE_API jsonbourne_val * jsonbourne_read | ( | const void * | src, |
| size_t | len ) |
Read strict JSON with default limits and malloc-backed ownership.
- Parameters
-
[in] src Immutable input bytes; no trailing NUL or padding is required. [in] len Exact input byte count.
- Returns
- Owning root released once with free(), or NULL on failure.
- See also
- jsonbourne_read_opts() when a diagnostic or relaxed syntax is needed.
Definition at line 1180 of file jsonbourne.c.
◆ jsonbourne_read_buf()
| JSONBOURNE_API jsonbourne_val * jsonbourne_read_buf | ( | const void * | src, |
| size_t | len, | ||
| jsonbourne_read_flag | flg, | ||
| const jsonbourne_read_limits * | limits, | ||
| void * | buf, | ||
| size_t | cap, | ||
| size_t * | required, | ||
| jsonbourne_read_err * | err ) |
Read a DOM into aligned caller storage without heap allocation.
- Parameters
-
[in] src Immutable input bytes, disjoint from buf. [in] len Input extent in bytes. [in] flg Named read-option mask. [in] limits Optional budgets; NULL selects linked defaults. [out] buf Storage with malloc-compatible alignment; NULL probes capacity. [in] cap Available bytes at buf. [out] required Optional exact size after successful validation, even if storage is too small; zero if validation fails. [out] err Optional diagnostic, including storage/alignment failures.
- Returns
- Root in buf, or NULL on failure; never free this root separately.
- Note
- A missing/short buffer reports MEMORY_ALLOCATION and is not written. The arena must outlive all returned nodes, strings and borrowed views.
Parse into aligned caller storage. On insufficient capacity, required is set.
Definition at line 1123 of file jsonbourne.c.
◆ jsonbourne_read_limits_default()
| JSONBOURNE_API struct jsonbourne_read_limits jsonbourne_read_limits_default | ( | void | ) |
Create default budgets using the linked implementation's reader limit.
- Returns
- Fully initialized limits with pointer-safe byte bounds and no tighter application policy for value count or individual string length.
- Note
- These defaults are not a whole-application memory budget; reduce them for inputs that must fit a particular arena or embedded workload.
Definition at line 106 of file jsonbourne.c.
◆ jsonbourne_read_measure()
| JSONBOURNE_API int jsonbourne_read_measure | ( | const void * | src, |
| size_t | len, | ||
| jsonbourne_read_flag | flg, | ||
| const jsonbourne_read_limits * | limits, | ||
| size_t * | required, | ||
| jsonbourne_read_err * | err ) |
Validate input and measure the exact single-allocation DOM size.
- Parameters
-
[in] src Input bytes; NULL is permitted only when len is zero. [in] len Input byte count, including any trailing trivia. [in] flg Named read options combined with bitwise OR. [in] limits Optional budgets; NULL selects linked defaults. [out] required Optional exact allocation size; zero on failure. [out] err Optional diagnostic; populated on success and failure.
- Return values
-
1 The complete input is valid within all effective limits. 0 Syntax, encoding, arguments or resource checks failed.
- Note
- Does not allocate or retain input pointers. The same parser is used for sizing and materialization so resource checks cannot disagree with allocation.
Validate and return the exact single-allocation size without allocating.
Definition at line 1043 of file jsonbourne.c.
◆ jsonbourne_read_opts()
| JSONBOURNE_API jsonbourne_val * jsonbourne_read_opts | ( | const void * | src, |
| size_t | len, | ||
| jsonbourne_read_flag | flg, | ||
| void *(* | alc_fn )(void *, size_t), | ||
| void * | alc_ctx, | ||
| jsonbourne_read_err * | err ) |
Read with named options and the linked implementation's default limits.
- Parameters
-
[in] src Immutable input bytes. [in] len Input byte count. [in] flg Named read-option mask. [in] alc_fn Optional malloc-aligned allocator; NULL uses malloc. [in] alc_ctx Opaque allocation context. [out] err Optional diagnostic.
- Returns
- Root owning one allocation, or NULL on failure.
- See also
- jsonbourne_read_opts_with_limits() for custom allocator lifetime rules.
Definition at line 1174 of file jsonbourne.c.
◆ jsonbourne_read_opts_with_limits()
| JSONBOURNE_API jsonbourne_val * jsonbourne_read_opts_with_limits | ( | const void * | src, |
| size_t | len, | ||
| jsonbourne_read_flag | flg, | ||
| const jsonbourne_read_limits * | limits, | ||
| void *(* | alc_fn )(void *, size_t), | ||
| void * | alc_ctx, | ||
| jsonbourne_read_err * | err ) |
Validate against explicit budgets, then allocate the entire DOM once.
- Parameters
-
[in] src Immutable input extent; never retained by the returned tree. [in] len Input size in bytes. [in] flg Named read-option mask. [in] limits Optional budgets; NULL selects linked defaults. [in] alc_fn Optional allocator called as alc_fn(alc_ctx, byte_count); NULL uses malloc. Returned storage must have malloc-compatible alignment. [in] alc_ctx Opaque allocator context, forwarded unchanged. [out] err Optional read diagnostic.
- Returns
- Owning root, or NULL on failure; default-allocated roots use free().
- Note
- Custom allocators own their release policy, including rejected storage; no custom deallocator is available on this read interface.
Definition at line 1147 of file jsonbourne.c.
◆ jsonbourne_read_validate()
| JSONBOURNE_API int jsonbourne_read_validate | ( | const void * | src, |
| size_t | len, | ||
| jsonbourne_read_flag | flg, | ||
| const jsonbourne_read_limits * | limits, | ||
| jsonbourne_read_err * | err ) |
Validate the entire extent without allocating a DOM or changing input.
- Parameters
-
[in] src Input bytes; NULL is permitted only for a zero-length extent. [in] len Number of input bytes to inspect. [in] flg Named read-option mask. [in] limits Optional budgets; NULL selects linked defaults. [out] err Optional read diagnostic.
- Return values
-
1 Valid complete input within the selected budgets. 0 Invalid input, arguments, encoding or resource usage.
- See also
- jsonbourne_read_measure()
Definition at line 1060 of file jsonbourne.c.