mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
JsonArray::remove() and JsonObject::remove() now release the memory of strings
This commit is contained in:
@@ -14,13 +14,12 @@ class ZeroTerminatedRamString : public ZeroTerminatedRamStringConst {
|
||||
: ZeroTerminatedRamStringConst(str) {}
|
||||
|
||||
template <typename TMemoryPool>
|
||||
const char* save(TMemoryPool* memoryPool) const {
|
||||
StringSlot* save(TMemoryPool* memoryPool) const {
|
||||
if (!_str) return NULL;
|
||||
size_t n = size() + 1;
|
||||
void* dup = memoryPool->alloc(n);
|
||||
if (!dup) return NULL;
|
||||
memcpy(dup, _str, n);
|
||||
return static_cast<const char*>(dup);
|
||||
StringSlot* slot = memoryPool->allocFrozenString(n);
|
||||
if (slot) memcpy(slot->value, _str, n);
|
||||
return slot;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user