Before moving from short to long, I init() the buffer struct and Char * data is reset to nullptr:
MyString & MyString::copy(const char *cstr, unsigned int length)
{
if ( !bufferIsLongString() ) init();
setLongShortStringFlag ( (length <= SHORT_STRING_CAPACTY) ? 0 : 1);
...
I can't figure why, but even if I try null to realloc, it fail on:
char * newbuffer = (char *)realloc(nullptr, maxStrLen + 1);
if ( newbuffer == nullptr ) Serial.println (" allocation failed ");
anyway, Coding_Badly is right about the way I acces my data is wrong.
For what I read, it is probably cause by this. I will try to use an enum class instead of a inner flag to check the string length.