From d20e64187b0e2ffedbfde6d657223862c7f0ef1a Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 9 Oct 2023 14:47:47 +0200 Subject: [PATCH] Use only one byte for the reference counter on 8-bit platforms --- src/ArduinoJson/Memory/StringNode.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ArduinoJson/Memory/StringNode.hpp b/src/ArduinoJson/Memory/StringNode.hpp index 4f35e492..88979cd7 100644 --- a/src/ArduinoJson/Memory/StringNode.hpp +++ b/src/ArduinoJson/Memory/StringNode.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include // offsetof @@ -15,9 +16,13 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 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::type; + struct StringNode* next; uint16_t length; - uint16_t references; + references_type references; char data[1]; static constexpr size_t maxLength = numeric_limits::highest();