mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Changing String append to use realloc(); thanks to Paul Stoffregen.
http://code.google.com/p/arduino/issues/detail?id=332
This commit is contained in:
@ -150,13 +150,15 @@ const String & String::operator+=( const String &other )
|
|||||||
_length += other._length;
|
_length += other._length;
|
||||||
if ( _length > _capacity )
|
if ( _length > _capacity )
|
||||||
{
|
{
|
||||||
char *temp = _buffer;
|
char *temp = (char *)realloc(_buffer, _length + 1);
|
||||||
getBuffer( _length );
|
if ( temp != NULL ) {
|
||||||
if ( _buffer != NULL )
|
_buffer = temp;
|
||||||
strcpy( _buffer, temp );
|
_capacity = _length;
|
||||||
free(temp);
|
} else {
|
||||||
|
_length -= other._length;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( _buffer != NULL )
|
|
||||||
strcat( _buffer, other._buffer );
|
strcat( _buffer, other._buffer );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user