This is my base layer, a "personal standard library" per se. The basic ideas in it are:
- Null-terminated strings should be avoided whenever possible, always use counted strings;
- Subscripts (indices, sizes, counts) should be signed;
- Arenas trivialize a lot of allocation patterns, specially temporary dynamic allocations;
- String functions should almost always return empty slices into the input string instead of returning
STRNULL. This avoids UBs when doing pointer arithmetic by guaranteeing that the returned returned strings are also ranges inside the input string; - Errors are returned as the optional, last output parameter. If passed
NULL, then it traps on error; MemoryCopy()and friends are just likememcpy()and others, except they check forsize == 0and early exit (because UB);- A
ThreadContextglobal for general temporary allocation, logging, and panic handling. All configurable; - My own
printfreplacement to support all those custom data types;