r/C_Programming • • 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.

cvr_string.h

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.

14 Upvotes

6 comments sorted by

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

  • ✅ Established Community (⭐ 232 stars)
  • ✅ Mature Repository (30+ days old)
  • ✅ Licensed under MIT
  • ❌ No Security Policy
  • ✅ Verified Organization Account
  • ℹ️ Unsigned Commits

Repository: someotherself/cvr_libs

Score: 1/6

  • ❌ Low Star Count (⭐ 0 / 4 required)
  • ❌ New Repository (under 30 days old)
  • ✅ Licensed under NOASSERTION
  • ❌ No Security Policy
  • ℹ️ Personal Account Repository
  • ℹ️ Unsigned Commits