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

Function add

src/ArduinoJson/Memory/StringPool.hpp:45–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44 template <typename TAdaptedString>
45 StringNode* add(TAdaptedString str, Allocator* allocator) {
46 ARDUINOJSON_ASSERT(str.isNull() == false);
47
48 auto node = get(str);
49 if (node) {
50 node->references++;
51 return node;
52 }
53
54 size_t n = str.size();
55
56 node = StringNode::create(n, allocator);
57 if (!node)
58 return nullptr;
59
60 stringGetChars(str, node->data, n);
61 node->data[n] = 0; // force NUL terminator
62 add(node);
63 return node;
64 }
65
66 void add(StringNode* node) {
67 ARDUINOJSON_ASSERT(node != nullptr);

Callers

nothing calls this directly

Calls 5

getFunction · 0.85
createFunction · 0.85
stringGetCharsFunction · 0.50
isNullMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected