FastSafeStrings (safe, fast string library for C/C++)

2 pointsposted 8 hours ago
by Clemcl

3 Comments

Clemcl

8 hours ago

I’ve been working on a C string library called FastSafeStrings.

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

Clemcl

8 hours ago

Happy to answer questions.

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.

Whoozat2020

5 hours ago

Wow! 7x performance? I'm giving this a try!

Out of a Cyber Security interest, does this solve buffer overruns dead in their tracks?