Documentation Index
Fetch the complete documentation index at: https://docs.boxlite.ai/llms.txt
Use this file to discover all available pages before exploring further.
Memory Management
Rules
-
All allocated strings must be freed
boxlite_box_id()->boxlite_free_string()boxlite_list_info()->boxlite_free_string()- Info/metrics JSON ->
boxlite_free_string()
-
Error structs must be freed
CBoxliteError->boxlite_error_free()
-
Results must be freed
CBoxliteExecResult->boxlite_result_free()
- All cleanup functions are NULL-safe
Functions
boxlite_free_string
Free a string allocated by BoxLite.Use this for any string returned by BoxLite API functions such as
boxlite_box_id(), boxlite_list_info(), boxlite_get_info(), boxlite_box_info(), boxlite_runtime_metrics(), and boxlite_box_metrics(). Safe to call with NULL.boxlite_error_free
Free error struct (message only - struct itself is stack-allocated).boxlite_result_free
Free an execution result.boxlite_simple_free
Free a simple box (auto-stops and removes).boxlite_runtime_free
Free a runtime instance.Memory Ownership Summary
| Returned By | Free With |
|---|---|
boxlite_box_id() | boxlite_free_string() |
boxlite_list_info() (out_json) | boxlite_free_string() |
boxlite_get_info() (out_json) | boxlite_free_string() |
boxlite_box_info() (out_json) | boxlite_free_string() |
boxlite_runtime_metrics() (out_json) | boxlite_free_string() |
boxlite_box_metrics() (out_json) | boxlite_free_string() |
boxlite_simple_run() (out_result) | boxlite_result_free() |
CBoxliteError (from any function) | boxlite_error_free() |
boxlite_version() | Do not free (static string) |
JSON Schema Reference
BoxOptions Schema
Required Fields
All BoxOptions JSON must include these fields:Field Reference
| Field | Type | Default | Description |
|---|---|---|---|
rootfs | object | Required | Root filesystem source |
cpus | integer | 2 | Number of CPUs |
memory_mib | integer | 512 | Memory in MiB |
disk_size_gb | integer | null | Disk size in GB |
working_dir | string | null | Working directory |
env | array | Required | Environment variables as [key, value] pairs |
volumes | array | Required | Volume mounts |
network | string | Required | Network mode: "Isolated" |
ports | array | Required | Port mappings |
auto_remove | boolean | true | Remove box when stopped |
RootfsSpec
VolumeSpec
PortSpec
Building JSON in C
Since C has no native JSON support, here are common approaches for constructing BoxOptions JSON:String Concatenation
Using snprintf for Dynamic Values
With Environment Variables
With Volumes and Ports
Thread Safety
| Component | Thread Safety |
|---|---|
CBoxliteRuntime | Thread-safe |
CBoxHandle | NOT thread-safe - do not share across threads |
CBoxliteSimple | NOT thread-safe - do not share across threads |
| Callbacks | Invoked on the calling thread |
Safe Multi-threaded Usage
Callback Threading
Callbacks passed toboxlite_execute are always invoked on the calling thread. This means:
- You do not need to synchronize within the callback itself
- The callback blocks the execution until it returns
- Heavy processing in callbacks will slow down command execution

