From d97f473e4adeb6869bec7d703c0d7b34a1f74059 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 20 May 2025 14:46:54 +0000 Subject: [PATCH] include proper header for allocator and mark the functions as override --- esphome/components/json/json_util.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index a9c6821112..c55ee4e401 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -1,6 +1,8 @@ #include "json_util.h" #include "esphome/core/log.h" +#include + namespace esphome { namespace json { @@ -11,13 +13,15 @@ static auto ALLOCATOR = RAMAllocator( // Build an allocator for the JSON Library using the RAMAllocator class struct SpiRamAllocator : ArduinoJson::Allocator { - void *allocate(size_t size) { return ALLOCATOR.allocate(size); } + void *allocate(size_t size) override { return ALLOCATOR.allocate(size); } - void deallocate(void *pointer) { + void deallocate(void *pointer) override { free(pointer); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) } - void *reallocate(void *ptr, size_t new_size) { return ALLOCATOR.reallocate(static_cast(ptr), new_size); } + void *reallocate(void *ptr, size_t new_size) override { + return ALLOCATOR.reallocate(static_cast(ptr), new_size); + } }; static auto DOC_ALLOCATOR = SpiRamAllocator();