_l0_h_string struct

Defined in module l0_runtime (l0_runtime.h).

Heap-allocated L0 string header.

L0 string: length-tracked, reference counted, immutable character sequence. Strings are always length-tracked to prevent out-of-bounds access. An l0_string with len=0 represents an empty string. Data should be NULL for empty strings to maintain consistency, but non-NULL is tolerated. refcount is used for memory management; if refcount == INT32_MAX, the string is not reference counted (e.g. allocated strings). Strings with refcount > 0 are reference counted and should be freed when refcount reaches zero. Strings with refcount == INT32_MAX are not ref-counted, but heap-allocated or empty, and should be freed manually. Strings with refcount == _RT_MEM_SENTINEL have already been freed (double-free detected). Data is null-terminated for C interoperability, but length is authoritative.

Public attributes

l0_int refcount
Reference count for memory management, or INT32_MAX if not reference counted.
l0_int len
Length in bytes (must be >= 0)
char bytes
Mutable character data, 0-terminated for C interoperability.