Strings

Immutable, length-aware string views that prevent buffer overflows.

Concept & Motivation

The Problem: Standard C strings (char*) are null-terminated. Calculating their length is O(N)O(N), and missing a null terminator causes buffer overflows (e.g., Heartbleed).

The Solution: Camelot Strings are Fat Pointers. They store the pointer and the length together.

circle-check

Buffer Safety

Architecture

Defined in include/types/string.h.

typedef struct {
    u8 *ptr;   // Pointer to data (NOT owned)
    u64 len;   // Exact length
} String;

API Reference

string.from

Wraps a C-literal into a String view. Calculates length once at creation.

String s = string.from("Hello");

string.join

Concatenates two strings into a new string allocated on an Arena.

circle-info

Ownership

Unlike C++ std::string, Camelot strings do not own their memory. You do not "free" a string; you release the Arena it lives on.

Last updated