ok, i've try this:
unsigned char MyString::changeBuffer(unsigned int maxStrLen)
{
Serial.print("change buffer sixe: "); Serial.println(maxStrLen);
char *newbuffer = nullptr;
if ( !buffer.longString.data ) {
newbuffer = (char*) malloc (maxStrLen + 1);
Serial.println("try malloc");
}
else newbuffer = (char *)realloc(buffer.longString.data, maxStrLen + 1);
if (newbuffer) {
Serial.println("alocation succed");
buffer.longString.data = newbuffer;
buffer.longString.capacity = maxStrLen;
return 1;
}
return 0;
malloc have been tried, but failed to.
It failed on the newbuffer pointer... I really do not understand....