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 committed Jan 4, 2024
1 parent ef9f004 commit b0b9764
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 @@ -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;
}

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

Expand Down

0 comments on commit b0b9764

Please sign in to comment.