mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 08:48:27 +01:00
Fixed object keys not being duplicated
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Strings/StringInMemoryPool.hpp"
|
||||
#include "MemoryPool.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -77,9 +78,9 @@ class DynamicMemoryPoolBase : public MemoryPool {
|
||||
_head = 0;
|
||||
}
|
||||
|
||||
class String {
|
||||
class StringBuilder {
|
||||
public:
|
||||
String(DynamicMemoryPoolBase* parent)
|
||||
explicit StringBuilder(DynamicMemoryPoolBase* parent)
|
||||
: _parent(parent), _start(NULL), _length(0) {}
|
||||
|
||||
void append(char c) {
|
||||
@@ -97,7 +98,7 @@ class DynamicMemoryPoolBase : public MemoryPool {
|
||||
_length++;
|
||||
}
|
||||
|
||||
const char* c_str() {
|
||||
StringInMemoryPool complete() {
|
||||
append(0);
|
||||
return _start;
|
||||
}
|
||||
@@ -108,8 +109,8 @@ class DynamicMemoryPoolBase : public MemoryPool {
|
||||
size_t _length;
|
||||
};
|
||||
|
||||
String startString() {
|
||||
return String(this);
|
||||
StringBuilder startString() {
|
||||
return StringBuilder(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Polyfills/mpl/max.hpp"
|
||||
#include "../Strings/StringInMemoryPool.hpp"
|
||||
#include "MemoryPool.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class StaticMemoryPoolBase : public MemoryPool {
|
||||
public:
|
||||
class String {
|
||||
class StringBuilder {
|
||||
public:
|
||||
String(StaticMemoryPoolBase* parent) : _parent(parent) {
|
||||
explicit StringBuilder(StaticMemoryPoolBase* parent) : _parent(parent) {
|
||||
_start = parent->_buffer + parent->_size;
|
||||
}
|
||||
|
||||
@@ -24,7 +25,7 @@ class StaticMemoryPoolBase : public MemoryPool {
|
||||
}
|
||||
}
|
||||
|
||||
const char* c_str() const {
|
||||
StringInMemoryPool complete() const {
|
||||
if (_parent->canAlloc(1)) {
|
||||
char* last = static_cast<char*>(_parent->doAlloc(1));
|
||||
*last = '\0';
|
||||
@@ -65,8 +66,8 @@ class StaticMemoryPoolBase : public MemoryPool {
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
String startString() {
|
||||
return String(this);
|
||||
StringBuilder startString() {
|
||||
return StringBuilder(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user