Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By xtal
#38060 Thx - I sure wasn't thinking about ram/flash....

I saw the following example , but reserve does not display red, however code compile.

String inputString = "";
inputString.reserve(1024); // reserve buffer

is reserve() valid on ESP?
User avatar
By martinayotte
#38064 What do you mean by "not display red" ?
Yes, reserve() exist in cores/esp8266/WString.cpp, but be aware that the string pointer itself in the stack when local, but the buffer itself is in the heap since it is been created with malloc().
User avatar
By xtal
#38067 The string .xxxx statements appear red/orange which I assume means they're are valid..
it apparently did not compile correctly .. did nothing but dump.....

Can you define a maximum string length so that free memory won't be changing when your string is less than maximum ,, 1 of my string vars will be 0 - 1023 bytes
User avatar
By martinayotte
#38070 Honestly, I never understood Arduino IDE highlighting, because some function like memset() becomes in red, while some other such as snprintf() won't. Their algorithm is probably funky, so, I don't bother.

For the allocation, yes, that why the reserve() exist, predefining it prevent tons of realloc/copy while doing multiple concatenates, for example.