mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
fix String bug
length where returning something that is not 0 while buffer where NULL!?
This commit is contained in:
parent
49536c78d3
commit
7ea4eb452d
@ -121,6 +121,7 @@ ICACHE_FLASH_ATTR String::~String() {
|
||||
if(buffer) {
|
||||
free(buffer);
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
// /*********************************************/
|
||||
@ -136,8 +137,7 @@ inline void String::init(void) {
|
||||
void ICACHE_FLASH_ATTR String::invalidate(void) {
|
||||
if(buffer)
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
capacity = len = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
unsigned char ICACHE_FLASH_ATTR String::reserve(unsigned int size) {
|
||||
|
@ -76,7 +76,11 @@ class String {
|
||||
// invalid string (i.e., "if (s)" will be true afterwards)
|
||||
unsigned char reserve(unsigned int size);
|
||||
inline unsigned int length(void) const {
|
||||
if(buffer) {
|
||||
return len;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// creates a copy of the assigned value. if the value is null or
|
||||
|
Loading…
x
Reference in New Issue
Block a user