File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -136,19 +136,21 @@ class SpyingAllocator : public ArduinoJson::Allocator {
136
136
137
137
class ControllableAllocator : public ArduinoJson ::Allocator {
138
138
public:
139
- ControllableAllocator () : _enabled(true ) {}
139
+ ControllableAllocator (
140
+ Allocator* upstream = ArduinoJson::detail::DefaultAllocator::instance())
141
+ : _enabled(true ), _upstream(upstream) {}
140
142
virtual ~ControllableAllocator () {}
141
143
142
144
void * allocate (size_t n) override {
143
- return _enabled ? malloc (n) : 0 ;
145
+ return _enabled ? _upstream-> allocate (n) : 0 ;
144
146
}
145
147
146
148
void deallocate (void * p) override {
147
- free (p);
149
+ _upstream-> deallocate (p);
148
150
}
149
151
150
152
void * reallocate (void * ptr, size_t n) override {
151
- return realloc (ptr, n);
153
+ return _upstream-> reallocate (ptr, n);
152
154
}
153
155
154
156
void disable () {
@@ -157,4 +159,5 @@ class ControllableAllocator : public ArduinoJson::Allocator {
157
159
158
160
private:
159
161
bool _enabled;
162
+ Allocator* _upstream;
160
163
};
You can’t perform that action at this time.
0 commit comments