This was partly inspired by older systems (PL/I-style descriptors and mainframe-style record processing), where strings and records are length-aware instead of repeatedly scanned.
The main idea is simple: a lot of C string work ends up rescanning the same data multiple times, and avoiding that can make a big difference in real workloads.
Clemcl•1h ago
The goal is to keep the performance of traditional C string handling while making it safer and avoiding repeated scans (strlen, strcat, delimiter searches).
Key ideas:
* Length-aware strings (O(1) length, no rescanning) * Bounds-safe operations (no buffer overruns) * Fixed-capacity model (no allocations) * Optional support for variable-length (VB-style) records to eliminate input scanning
In a simple real-world workload (processing 5M small records), it runs about ~7× faster than typical C code using fgets/strcat/strlen.
This is an early release — I’d really appreciate feedback on:
* API design (especially the macro-based C interface) * Benchmark fairness and methodology * Edge cases or safety concerns
GitHub: https://github.com/clemcl/FastSafeStrings