From b0b9764a23be75a75750c4b62aca38f76c575d46 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 4 Jan 2024 14:36:09 +0100 Subject: [PATCH] Use Utils::checkJsonAlloc in ConfigurationClass --- src/Configuration.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 7070f422..f191ab7c 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -4,6 +4,7 @@ */ #include "Configuration.h" #include "MessageOutput.h" +#include "Utils.h" #include "defaults.h" #include #include @@ -26,8 +27,7 @@ bool ConfigurationClass::write() DynamicJsonDocument doc(JSON_BUFFER_SIZE); - if (doc.capacity() == 0) { - MessageOutput.println("Failed to allocate memory"); + if (!Utils::checkJsonAlloc(doc, __FUNCTION__, __LINE__)) { return false; } @@ -157,8 +157,7 @@ bool ConfigurationClass::read() DynamicJsonDocument doc(JSON_BUFFER_SIZE); - if (doc.capacity() == 0) { - MessageOutput.println("Failed to allocate memory"); + if (!Utils::checkJsonAlloc(doc, __FUNCTION__, __LINE__)) { return false; } @@ -323,8 +322,7 @@ void ConfigurationClass::migrate() DynamicJsonDocument doc(JSON_BUFFER_SIZE); - if (doc.capacity() == 0) { - MessageOutput.println("Failed to allocate memory"); + if (!Utils::checkJsonAlloc(doc, __FUNCTION__, __LINE__)) { return; }