MCPcopy Create free account
hub / github.com/SmingHub/Sming / concat

Method concat

Sming/Wiring/WString.cpp:336–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334/*********************************************/
335
336bool String::concat(const char* cstr, size_t length)
337{
338 if(length == 0) {
339 return true; // Nothing to add
340 }
341 if(!cstr) {
342 return false; // Bad argument (length is non-zero)
343 }
344
345 auto len = this->length();
346 size_t newlen = len + length;
347
348 // Appending all or part of self requires special handling
349 auto buf = buffer();
350 if(cstr >= buf && cstr < (buf + len)) {
351 auto offset = cstr - buf;
352 if(!reserve(newlen)) {
353 return false;
354 }
355 buf = buffer();
356 memcpy(buf + len, buf + offset, length);
357 setlen(newlen);
358 return true;
359 }
360
361 if(!reserve(newlen)) {
362 return false;
363 }
364 memcpy(buffer() + len, cstr, length);
365 setlen(newlen);
366 return true;
367}
368
369bool String::concat(const FlashString& fstr)
370{

Callers 15

jquery.jsFile · 0.45
xbFunction · 0.45
UbFunction · 0.45
jquery.jsFile · 0.45
xbFunction · 0.45
UbFunction · 0.45
jquery.jsFile · 0.45
xbFunction · 0.45
UbFunction · 0.45
startWebServerFunction · 0.45
executeMethod · 0.45
executeMethod · 0.45

Calls 9

lengthMethod · 0.95
concatFunction · 0.85
ultoa_wpFunction · 0.85
ltoa_wpFunction · 0.85
lltoa_wpFunction · 0.85
ulltoa_wpFunction · 0.85
dtostrfFunction · 0.85
sizeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected