Comment by eis
12 years ago
Disadvantage #1 can be simply solved by using a pointer to the "sds" type instead.
Then you can be sure that
sdscat(&s, "Some more data")
updates s to always point at the right memory address and you can't introduce hard to find bugs by forgetting to assign to s which the compiler wont warn you about. If you'd pass just "s" instead of "&s" as the first parameter, the compiler would error out.
So all functions modifying the string should take a pointer to it.
To be consistent between allocation and reallocation (like malloc() and realloc()).
And you still want to access the old value if reallocation failed.