Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DynamicJsonDocument.hpp Source File

DynamicJsonDocument.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Document/BasicJsonDocument.hpp>
00008 
00009 #include <stdlib.h>  // malloc, free
00010 
00011 namespace ARDUINOJSON_NAMESPACE {
00012 
00013 struct DefaultAllocator {
00014   void* allocate(size_t size) {
00015     return malloc(size);
00016   }
00017 
00018   void deallocate(void* ptr) {
00019     free(ptr);
00020   }
00021 
00022   void* reallocate(void* ptr, size_t new_size) {
00023     return realloc(ptr, new_size);
00024   }
00025 };
00026 
00027 typedef BasicJsonDocument<DefaultAllocator> DynamicJsonDocument;
00028 
00029 }  // namespace ARDUINOJSON_NAMESPACE