News for hackers. Stuff that matters.
Re:Simple Dynamic Strings library for C, compatible with nul... by paulsmith on Tuesday December 03, 2019 @10:29AM (#21693109)
There is also Better String Library, similar self-contained library with C-style string compatibility:

http://bstring.sourceforge.net/

Re:Simple Dynamic Strings library for C, compatible with nul... by aidenn0 on Tuesday December 03, 2019 @12:13PM (#21694243)
TFA specifically names what is different between SDS and libraries like bstring:

> Normally dynamic string libraries for C are implemented using a structure that defines the string. The structure has a pointer field that is managed by the string function, so it looks like this:

    struct yourAverageStringLibrary {
        char *buf;
        size_t len;
        ... possibly more fields here ...
    };
> SDS strings as already mentioned don't follow this schema, and are instead a single allocation with a prefix that lives before the address actually returned for the string.
Re:Simple Dynamic Strings library for C, compatible with nul... by dho85 on Tuesday December 03, 2019 @01:02PM (#21694798)
What the page doesn't really acknowledge is that its "single allocation with a prefix" design is significantly more dangerous than the "separate struct" design. Particularly in that it's incompatible with the address sanitizer.