It fails when expanding the string with itself, as the input may be destroyed. C++ specs requires this for std::string, although not for std::vector.
String s = string_create("this is a short one");
string_append_cstr(&s, string_cstr(&s)); // fail
String s1 = string_create("try with a moderately long string");
String s2 = string_create("this allocation will probably force next expand of s1 to use a new address");
string_append_cstr(&s1, string_cstr(&s1)); // fail
I created a basic sso_string that utilizes all 23 out of 24 chars as a gist. It handles self append without copying the input before realloc. Btw, I see no (re)assign function, any reason?
It fails when expanding the string with itself, as the input may be destroyed. C++ specs requires this for std::string, although not for std::vector.
I created a basic sso_string that utilizes all 23 out of 24 chars as a gist. It handles self append without copying the input before realloc. Btw, I see no (re)assign function, any reason?