MCPcopy Create free account
hub / github.com/bblanchon/ArduinoJson / reserve

Function reserve

src/ArduinoJson/Memory/StringBuffer.hpp:20–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 }
19
20 char* reserve(size_t capacity) {
21 if (node_ && capacity > node_->length) {
22 // existing buffer is too small, we need to reallocate
23 resources_->destroyString(node_);
24 node_ = nullptr;
25 }
26 if (!node_)
27 node_ = resources_->createString(capacity);
28 if (!node_)
29 return nullptr;
30 size_ = capacity;
31 node_->data[capacity] = 0; // null-terminate the string
32 return node_->data;
33 }
34
35 JsonString str() const {
36 ARDUINOJSON_ASSERT(node_ != nullptr);

Callers

nothing calls this directly

Calls 2

destroyStringMethod · 0.80
createStringMethod · 0.80

Tested by

no test coverage detected