C Advanced API
Policy storage
Supply aligned policy-object storage for advanced C loaders without claiming a zero-allocation load.Use the _in() loaders when the application must own the policy object's memory. This is different from the input EDB's storage and from an explanation workspace. The regular loaders remain simpler when caller-owned policy memory is unnecessary.
Types
Used from other pages
These types are defined on the linked pages; this page uses them in the roles below.
| Type | Use on this page | Defined in |
|---|---|---|
maelys_datalog_policy_t | Output handle stored in caller-owned memory. | Stable Manifests |
maelys_datalog_diagnostic_t | Optional output argument receiving loading details. | Stable Errors |
Functions
| Function | Purpose |
|---|---|
maelys_datalog_policy_storage_requirements() | Ask the installed profile for policy-object size and alignment. |
maelys_datalog_policy_load_frontend_in() | Load inline source through a selected frontend into caller storage. |
maelys_datalog_policy_load_manifest_text_in() | Load a manifest bundle into that storage. |
Size the arena before loading
The size is a profile bound for up to eight policies, not an estimate from the current source. Ask once for both byte count and alignment. Pass an unused, aligned region of at least that size to an _in() loader; keep it alive until maelys_datalog_policy_free() closes the returned handle. After a failed load, the region may have been overwritten even though the output handle remains NULL.
maelys_datalog_status_t
maelys_datalog_policy_storage_requirements(
size_t *out_bytes,
size_t *out_alignment
);maelys_datalog_status_tOK with both measurements; otherwise no arena should be used for loading.
Load with a selected frontend
The frontend descriptor selects how source is lowered. Pass NULL for the built-in Datalog frontend. The domain must already be registered, just as with stable inline loading.
maelys_datalog_status_t
maelys_datalog_policy_load_frontend_in(
void *storage,
size_t storage_bytes,
const char *domain,
const char *policy_id,
const char *source,
size_t source_len,
const maelys_datalog_frontend_t *frontend,
maelys_datalog_policy_t **out_policy,
maelys_datalog_diagnostic_t *diagnostic
);maelys_datalog_status_tOK after a successful load; STORAGE_TOO_SMALL, INVALID_ARGUMENT or another error otherwise. There is no heap fallback for the policy object.
Ownership boundary
static maelys_datalog_status_t policy_arena_shape(
size_t *bytes, size_t *alignment) {
return maelys_datalog_policy_storage_requirements(bytes, alignment);
}The arena must not overlap source, manifest, output handle or diagnostic memory. policy_free() closes the handle but does not free caller storage. Sessions copy their prepared program; release policy handles according to the stable lifetime rules. This path removes an allocation for the policy object only. JSON parsing, contexts and extension callbacks may still allocate; it is not a zero-malloc guarantee for the whole load.