Re:Simple Dynamic Strings library for C, compatible with nul...
by jdsully on Wednesday December 04, 2019 @03:33AM
(#21700565)
You use sdslen() instead of strlen(). Ditto for everything else. Failure to do so results in subtle bugs.
Re:Simple Dynamic Strings library for C, compatible with nul...
by CJefferson on Wednesday December 04, 2019 @08:39AM
(#21702030)
Then (in my opinion) the library shouldn't advertise itself as compatible with Null terminated C strings, as users will assume that means they can use strlen (or more likely, other functions which use strlen themselves).
In a similar system I work on, we have a list of functions (like strlen, Strcat), where we carefully vet every occurrence in the code base. It's annoying but the only way to stop subtle bugs we've found.
Re:Simple Dynamic Strings library for C, compatible with nul...
by jdsully on Wednesday December 04, 2019 @01:17PM
(#21705112)
Redis doesn’t really have this problem because its mostly developed by Antirez.
How do you handle this?