File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/ArduinoJson/Strings/Adapters Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,16 @@ struct IsChar
2020class RamString {
2121 public:
2222 static const size_t typeSortKey = 2 ;
23+ #if ARDUINOJSON_SIZEOF_POINTER <= 2
24+ static constexpr size_t sizeMask = size_t (-1 ) >> 1 ;
25+ #else
26+ static constexpr size_t sizeMask = size_t (-1 );
27+ #endif
2328
2429 RamString (const char * str, size_t sz, bool linked = false )
25- : str_(str), size_(sz), linked_(linked) {}
30+ : str_(str), size_(sz & sizeMask), linked_(linked) {
31+ ARDUINOJSON_ASSERT (size_ == sz);
32+ }
2633
2734 bool isNull () const {
2835 return !str_;
@@ -48,8 +55,15 @@ class RamString {
4855
4956 protected:
5057 const char * str_;
58+
59+ #if ARDUINOJSON_SIZEOF_POINTER <= 2
60+ // Use a bitfield only on 8-bit microcontrollers
61+ size_t size_ : sizeof (size_t ) * 8 - 1 ;
62+ bool linked_ : 1 ;
63+ #else
5164 size_t size_;
52- bool linked_; // TODO: merge with size_
65+ bool linked_;
66+ #endif
5367};
5468
5569template <typename TChar>
You can’t perform that action at this time.
0 commit comments