r/C_Programming • u/Hoxitron • Oct 21 '26
A string library
Some time ago I was inspired by the string view library to focus on simpler things and do some recreational programming of my own. I had written very little C before, but spent a lot of time reading it, mostly the miniaudio source code, which I think still helped a lot.
This is a relatively small one, mostly practice for the next library in this repo. But I would really appreciate some feedback or review on my code.
There are more functions available compared to sv, plus a string type that owns it and can modify it (for now just appending), plus iterators over words, lines, or a delimiter. I tried to make everything as ergonomic as I could.
At the core of the library is also the two way string matching (Crochemore-Perrin) algorithm taken from the rust std library. I did include an explanation into how it works, but mine just follows a practical example. I found theoretical explanations to be too confusing (at least for my brain).
I don't think I am done with the algorithms. I think it may be useful to use different ones depending on the size of the haystack or needle. Plus, it seems like a good place to mess around with SIMD. However, I have no clue how to benchmark in C.
The library is C89 compatible for no other reason that I find it fun and challenging.
View all comments
•
u/github-guard Oct 21 '26
⚠️ GitHub Guard: Trust Warning
One or more repositories scored below the threshold (3), but the post was not removed.
Repository: tsoding/sv
Score: 4/6
Repository: someotherself/cvr_libs
Score: 1/6