FREE C, close to the metal LESSON · C, close to the metal
Reason about memory as regions
Layout, ownership, undefined behavior, and tools
C memory safety is a proof about every access, not a property of pointers in isolation.
Objects occupy regions with size, alignment, lifetime, and effective type. An access is valid only when the program has a live object, a pointer derived in an allowed way, and an in-bounds operation of the permitted representation. The compiler assumes undefined behavior never occurs, so a violation can corrupt state or invalidate source-level reasoning far from the original access.
For each pointer, be able to name the region, bounds, owner, lifetime, and allowed operations.
Optimization makes undefined behavior look supernatural.
Compilers remove checks, reorder operations, and infer impossible branches under the assumption that the program follows the language rules. Sanitizers, warnings, fuzzers, static analysis, and reduced test cases expose classes of violations, but none replaces a clear ownership design. Use narrow APIs that pair allocation and release and make lengths travel with buffers.
Tooling finds broken proofs; structure reduces how many proofs the program demands.