File tree Expand file tree Collapse file tree 4 files changed +103
-0
lines changed
no-member-named-reallocate Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ options:
3535 summary : Error says "`class Xxx` has no member named `read`"
3636 page : no-member-named-read.md
3737
38+ class-has-no-member-named-reallocate :
39+ label : " `class Xxx` has no member named `reallocate`; did you mean `deallocate`?"
40+ summary : Error says "`class Xxx` has no member named `reallocate`"
41+ page : no-member-named-reallocate/index.md
42+
3843 pointer-to-object :
3944 label : ' `const void*` is not a pointer-to-object type'
4045 summary : Error says "`const void*` is not a pointer-to-object type"
@@ -105,6 +110,11 @@ options:
105110 summary : Error says "`struct Xxx` has no member named `read`"
106111 page : no-member-named-read.md
107112
113+ struct-has-no-member-named-reallocate :
114+ label : " `struct Xxx` has no member named `reallocate`; did you mean `deallocate`?"
115+ summary : Error says "`struct Xxx` has no member named `reallocate`"
116+ page : no-member-named-reallocate/index.md
117+
108118 range-based-for-requires-begin :
109119 label : this range-based `for` statement requires a suitable "begin" function and none was found
110120 summary : Error says "this range-based `for` statement requires a suitable "begin" function and none was found"
Original file line number Diff line number Diff line change 1+ ---
2+ options :
3+ upgrade :
4+ label : Upgrade to ArduinoJson 7 syntax (recommended)
5+ summary : User wants to upgrade to ArduinoJson 7 syntax
6+ page : upgrade.md
7+ failure :
8+ label : Keep to ArduinoJson 6 syntax (quick fix)
9+ summary : User wants to keep to ArduinoJson 6 syntax
10+ page : keep.md
11+ ---
12+
13+ This error occurs when the following condition are met:
14+
15+ 1 . The program was designed for ArduinoJson 6.
16+ 2 . The program uses a custom allocator.
17+ 3 . The custom allocator doesn't define ` reallocate() ` .
18+
19+ Indeed, in ArduinoJson 6, the ` reallocate() ` method was optional for custom allocators.
20+ It's now mandatory in ArduinoJson 7, and that's why you get this error.
21+
22+ There are two ways to fix this issue. You can either:
Original file line number Diff line number Diff line change 1+ ---
2+ options :
3+ success :
4+ label : " Yes"
5+ summary : Adding the `reallocate()` method fixes the issue
6+ page : /done.md
7+ failure :
8+ label : " No"
9+ summary : Adding the `reallocate()` method doesn't fix the issue
10+ page : /deadend.md
11+ ---
12+
13+ You must add the ` reallocate() ` method like so:
14+
15+ ``` diff
16+ struct SpiRamAllocator {
17+ void* allocate(size_t size) {
18+ return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
19+ }
20+
21+ void deallocate(void* pointer) {
22+ heap_caps_free(pointer);
23+ }
24+
25+ + void* reallocate(void* ptr, size_t new_size) {
26+ + return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
27+ + }
28+ };
29+ ```
30+
31+ Did this solve your issue?
Original file line number Diff line number Diff line change 1+ ---
2+ options :
3+ success :
4+ label : " Yes"
5+ summary : Upgrading the syntax and adding the `reallocate()` method fixes the issue
6+ page : /done.md
7+ failure :
8+ label : " No"
9+ summary : Upgrading the syntax and adding the `reallocate()` method doesn't fix the issue
10+ page : /deadend.md
11+ ---
12+
13+ Here is how to upgrade your code:
14+
15+ ``` diff
16+ - struct SpiRamAllocator {
17+ + struct SpiRamAllocator : ArduinoJson::Allocator {
18+ void* allocate(size_t size) {
19+ return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
20+ }
21+
22+ void deallocate(void* pointer) {
23+ heap_caps_free(pointer);
24+ }
25+
26+ + void* reallocate(void* ptr, size_t new_size) {
27+ + return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
28+ + }
29+ };
30+
31+ - using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;
32+ + SpiRamAllocator allocator;
33+
34+ - SpiRamJsonDocument doc;
35+ + JsonDocument doc(&allocator);
36+ ```
37+
38+ For more information about the changes in ArduinoJson 7, please refer to the [ upgrade guide] ( /v7/how-to/upgrade-from-v6/ ) .
39+
40+ Did this solve your issue?
You can’t perform that action at this time.
0 commit comments