From 3cca7a61614368785aac4f92903f39d0d75d8f34 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 14 Jul 2025 12:31:41 -1000 Subject: [PATCH] fix incorrect comment --- esphome/components/json/json_util.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index 5f47444582..94c531222a 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -15,9 +15,10 @@ struct SpiRamAllocator : ArduinoJson::Allocator { void deallocate(void *pointer) override { // ArduinoJson's Allocator interface doesn't provide the size parameter in deallocate. // RAMAllocator::deallocate() requires the size, which we don't have access to here. - // Since RAMAllocator internally uses malloc/free for NONE mode (PSRAM allocation), - // it's safe to use free() directly. The memory was allocated via malloc in - // RAMAllocator::allocate() when using NONE mode. + // RAMAllocator::deallocate implementation just calls free() regardless of whether + // the memory was allocated with heap_caps_malloc or malloc. + // This is safe because ESP-IDF's heap implementation internally tracks the memory region + // and routes free() to the appropriate heap. free(pointer); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) }