From 24c8a40fadf69fdaec4aee657c901d4c15862753 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 4821c8ed6..ff593e22a 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; } @@ -232,8 +232,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; } @@ -473,8 +472,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; }