mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 02:37:35 +02:00
Use only one byte for the reference counter on 8-bit platforms
This commit is contained in:
@ -7,6 +7,7 @@
|
|||||||
#include <ArduinoJson/Memory/Allocator.hpp>
|
#include <ArduinoJson/Memory/Allocator.hpp>
|
||||||
#include <ArduinoJson/Namespace.hpp>
|
#include <ArduinoJson/Namespace.hpp>
|
||||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||||
|
#include <ArduinoJson/Polyfills/integer.hpp>
|
||||||
#include <ArduinoJson/Polyfills/limits.hpp>
|
#include <ArduinoJson/Polyfills/limits.hpp>
|
||||||
|
|
||||||
#include <stddef.h> // offsetof
|
#include <stddef.h> // offsetof
|
||||||
@ -15,9 +16,13 @@
|
|||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
struct StringNode {
|
struct StringNode {
|
||||||
|
// Use the same type as SlotId to store the reference count
|
||||||
|
// (there can never be more references than slots)
|
||||||
|
using references_type = uint_t<ARDUINOJSON_SLOT_ID_SIZE * 8>::type;
|
||||||
|
|
||||||
struct StringNode* next;
|
struct StringNode* next;
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
uint16_t references;
|
references_type references;
|
||||||
char data[1];
|
char data[1];
|
||||||
|
|
||||||
static constexpr size_t maxLength = numeric_limits<uint16_t>::highest();
|
static constexpr size_t maxLength = numeric_limits<uint16_t>::highest();
|
||||||
|
Reference in New Issue
Block a user