Arduino/Teensyduino String object

Status
Not open for further replies.

dlchambers

Well-known member
There's a lot out there re: the Arduino String object, mostly people saying "it's broken, don't use it".
I've also read posts (by Paul S and others) that say that String works in Teensyduino land.

But I haven't seen any recent info on this.
Does anyone have any definitive info as to whether String is reliable on Teensyduino?

Note that I'm trying to decouple this from the debate over "should one ever use embedded malloc".
For the context of this question let's just assume that I'm OK with using malloc() and am therefore specifically interested in knowing whether String is useable or if it still eventually leads to memory leaking/corruption.

Many thanks,
-Dave
 
Yes, if you're philosophically ok with heap-based memory allocation, String works fine.

For cases where you incrementally increase the length of a String, the reserve() function lets you pre-allocate the memory, which is far more efficient and often avoids memory fragmentation issues.

In the unlikely case you do find any bugs in String, please report them here with a test case and I will fix them!
 
Status
Not open for further replies.
Back
Top