1. 8

This is related to this thread How to C (as of 2016)


  2. 2

    I like that people are thinking about this problem, but I think this is the wrong approach.

    To me, the attempt at compatibility with C-strings, and the C-strings library is asking for trouble. As soon as an sds allocated string gets modified by a seemingly C-string compatible library, you might be toast, since there are fields that the C-string functions have no idea about.

    I think the only way to build a safer string library, and be “compatible” with existing C-string code, which is necessary for interacting with the operating system and such, is to just strdup your internal buffer out to a C-string and then merge any changes, or compatible replacements back into your string library’s buffers, with your libraries functions. Giving your buffers to code that’s doing who knows what is just asking for trouble.

    I’m also curious as to why reallocations do a x2 instead of x1.5, for which I’ve seen many claims that it’s optimal.