mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 16:14:19 +01:00
Inverted dependency between MemoryPool and string adapters.
Inserted a null after each raw string in the pool.
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Memory/MemoryPool.hpp>
|
||||
#include <ArduinoJson/Polyfills/pgmspace.hpp>
|
||||
#include <ArduinoJson/Strings/IsString.hpp>
|
||||
#include <ArduinoJson/Strings/StoragePolicy.hpp>
|
||||
@@ -33,14 +32,8 @@ class FlashStringAdapter {
|
||||
return !_str;
|
||||
}
|
||||
|
||||
char* save(MemoryPool* pool) const {
|
||||
if (!_str)
|
||||
return NULL;
|
||||
size_t n = size() + 1; // copy the terminator
|
||||
char* dup = pool->allocFrozenString(n);
|
||||
if (dup)
|
||||
memcpy_P(dup, reinterpret_cast<const char*>(_str), n);
|
||||
return dup;
|
||||
void copyTo(char* p, size_t n) const {
|
||||
memcpy_P(p, reinterpret_cast<const char*>(_str), n);
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
@@ -49,7 +42,7 @@ class FlashStringAdapter {
|
||||
return strlen_P(reinterpret_cast<const char*>(_str));
|
||||
}
|
||||
|
||||
typedef storage_policy::store_by_copy storage_policy;
|
||||
typedef storage_policies::store_by_copy storage_policy;
|
||||
|
||||
private:
|
||||
const __FlashStringHelper* _str;
|
||||
|
||||
Reference in New Issue
Block a user