mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Renamed JsonBuffer to MemoryPool
This commit is contained in:
@@ -14,10 +14,10 @@ class ArduinoString {
|
||||
ArduinoString(const ::String& str) : _str(&str) {}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
if (is_null()) return NULL;
|
||||
size_t n = _str->length() + 1;
|
||||
void* dup = buffer->alloc(n);
|
||||
void* dup = memoryPool->alloc(n);
|
||||
if (dup != NULL) memcpy(dup, _str->c_str(), n);
|
||||
return static_cast<const char*>(dup);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ class FixedSizeFlashString {
|
||||
}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
if (!_str) return NULL;
|
||||
void* dup = buffer->alloc(_size);
|
||||
void* dup = memoryPool->alloc(_size);
|
||||
if (dup != NULL) memcpy_P(dup, (const char*)_str, _size);
|
||||
return static_cast<const char*>(dup);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ class FixedSizeRamString {
|
||||
}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
if (!_str) return NULL;
|
||||
void* dup = buffer->alloc(_size);
|
||||
void* dup = memoryPool->alloc(_size);
|
||||
if (!dup) return NULL;
|
||||
memcpy(dup, _str, _size);
|
||||
return static_cast<const char*>(dup);
|
||||
|
||||
@@ -14,9 +14,9 @@ class StlString {
|
||||
StlString(const std::string& str) : _str(&str) {}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
size_t n = _str->length() + 1;
|
||||
void* dup = buffer->alloc(n);
|
||||
void* dup = memoryPool->alloc(n);
|
||||
if (dup != NULL) memcpy(dup, _str->c_str(), n);
|
||||
return static_cast<const char*>(dup);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ class ZeroTerminatedFlashString {
|
||||
}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
if (!_str) return NULL;
|
||||
size_t n = size() + 1; // copy the terminator
|
||||
void* dup = buffer->alloc(n);
|
||||
void* dup = memoryPool->alloc(n);
|
||||
if (dup != NULL) memcpy_P(dup, (const char*)_str, n);
|
||||
return static_cast<const char*>(dup);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ class ZeroTerminatedRamString {
|
||||
}
|
||||
|
||||
template <typename Buffer>
|
||||
const char* save(Buffer* buffer) const {
|
||||
const char* save(Buffer* memoryPool) const {
|
||||
if (!_str) return NULL;
|
||||
size_t n = size() + 1;
|
||||
void* dup = buffer->alloc(n);
|
||||
void* dup = memoryPool->alloc(n);
|
||||
if (!dup) return NULL;
|
||||
memcpy(dup, _str, n);
|
||||
return static_cast<const char*>(dup);
|
||||
|
||||
Reference in New Issue
Block a user