Skip to content

Commit

Permalink
Use Utils::checkJsonAlloc in ConfigurationClass
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody authored and helgeerbe committed Jan 5, 2024
1 parent f968179 commit 24c8a40
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
#include "Configuration.h"
#include "MessageOutput.h"
#include "Utils.h"
#include "defaults.h"
#include <ArduinoJson.h>
#include <LittleFS.h>
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 24c8a40

Please sign in to comment.