Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
So, I wrote a new library recently that works produces and consumes strings in the form that C already uses them in (making them more easily usable everywhere) - https://github.com/lelanthran/libds/blob/v1.0.5/src/ds_str.h
The commit history is...very clean https://github.com/alcover/buf/commits/master
I've developped my own string library 15 years ago and used it in payment terminals with rather limited memory. if you are so concerned with string size, 2 bytes is enough for 65535 characters, which is enough for nearly everything. You are never going to allocate 8 bytes/string, that's stupid. If you need to work on more than that (a text editor for instance) you are not going to use C strings anyway, but some more complicated data structure. If you think adding 2 bytes per string is a problem, you probably are optimizing the wrong way. Pascal strings have been used since the 1970s and AFAIK have never been a problem memory-wise. And that's normal since they took exactly the same size as C strings.
How does this compare to https://github.com/antirez/sds ?
Are you aware of the STB Stretchy Buffer? https://github.com/nothings/stb/blob/master/stretchy_buffer.h
Related posts
- Strings In C Tiring And Unsafe So I Just Made
-
nanoprintf VS callback_printf - a user suggested alternative
2 projects | 16 Aug 2023
- A convenient C string API, friendly alongside classic C strings.
- Show HN
- STM32Cube IDE: how do you override the existing start-up code with a vector table defined in C code?