mirror of
https://github.com/esphome/esphome.git
synced 2025-08-03 17:07:54 +00:00
address bot comments
This commit is contained in:
parent
a714e8da0b
commit
52d6801618
@ -83,8 +83,7 @@ void HttpRequestUpdate::update_task(void *params) {
|
||||
container.reset(); // Release ownership of the container's shared_ptr
|
||||
|
||||
valid = json::parse_json(response, [this_update](JsonObject root) -> bool {
|
||||
if (!root["name"].is<const char *>() || !root["version"].is<const char *>() ||
|
||||
!root["builds"].is<const char *>()) {
|
||||
if (!root["name"].is<const char *>() || !root["version"].is<const char *>() || !root["builds"].is<JsonArray>()) {
|
||||
ESP_LOGE(TAG, "Manifest does not contain required fields");
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "json_util.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <ArduinoJson/Memory/Allocator.hpp>
|
||||
// ArduinoJson::Allocator is included via ArduinoJson.h in json_util.h
|
||||
|
||||
namespace esphome {
|
||||
namespace json {
|
||||
@ -13,7 +13,11 @@ struct SpiRamAllocator : ArduinoJson::Allocator {
|
||||
void *allocate(size_t size) override { return this->allocator_.allocate(size); }
|
||||
|
||||
void deallocate(void *pointer) override {
|
||||
// RAMAllocator requires passing the size of the allocated space which don't know, so use free directly
|
||||
// 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.
|
||||
free(pointer); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user