File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
hardware/arduino/cores/arduino Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ inline void String::init(void)
114
114
115
115
unsigned char String::reserve (unsigned int size)
116
116
{
117
- if (capacity >= size) return 1 ;
117
+ if (buffer && capacity >= size) return 1 ;
118
118
if (changeBuffer (size)) {
119
119
if (len == 0 ) buffer[0 ] = 0 ;
120
120
return 1 ;
@@ -139,11 +139,6 @@ unsigned char String::changeBuffer(unsigned int maxStrLen)
139
139
140
140
String & String::copy (const char *cstr, unsigned int length)
141
141
{
142
- if (length == 0 ) {
143
- if (buffer) buffer[0 ] = 0 ;
144
- len = 0 ;
145
- return *this ;
146
- }
147
142
if (!reserve (length)) {
148
143
if (buffer) {
149
144
free (buffer);
@@ -204,6 +199,11 @@ String & String::operator = (const char *cstr)
204
199
if (cstr) {
205
200
copy (cstr, strlen (cstr));
206
201
} else {
202
+ if (buffer) {
203
+ free (buffer);
204
+ capacity = 0 ;
205
+ buffer = NULL ;
206
+ }
207
207
len = 0 ;
208
208
}
209
209
return *this ;
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class String
43
43
{
44
44
public:
45
45
// constructors
46
- String (const char *cstr = NULL );
46
+ String (const char *cstr = " " );
47
47
String (const String &str);
48
48
#ifdef __GXX_EXPERIMENTAL_CXX0X__
49
49
String (String &&rval);
You can’t perform that action at this time.
0 commit comments