From b587d0af232263af6fced5ea2d7a67b31af7355d Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sun, 3 Nov 2024 11:43:02 +0100 Subject: [PATCH] Revert heap_caps_free to cJSON_free --- code/components/fileserver_ota/server_file.cpp | 6 +++--- code/components/gpio_ctrl/gpioPin.cpp | 2 +- code/components/mainprocess_ctrl/ClassFlowMQTT.cpp | 2 +- code/components/mainprocess_ctrl/ClassFlowWebhook.cpp | 2 +- code/components/mqtt_ctrl/server_mqtt.cpp | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/components/fileserver_ota/server_file.cpp b/code/components/fileserver_ota/server_file.cpp index e0f9f8c5c..1f8ab6228 100644 --- a/code/components/fileserver_ota/server_file.cpp +++ b/code/components/fileserver_ota/server_file.cpp @@ -92,7 +92,7 @@ esp_err_t getDataFileList(httpd_req_t *req) if (jsonChar != NULL) { retVal = httpd_resp_send(req, jsonChar, strlen(jsonChar)); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } return retVal; @@ -147,7 +147,7 @@ esp_err_t getTfliteFileList(httpd_req_t *req) if (jsonChar != NULL) { retVal = httpd_resp_send(req, jsonChar, strlen(jsonChar)); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } return retVal; @@ -199,7 +199,7 @@ esp_err_t getCertFileList(httpd_req_t *req) if (jsonChar != NULL) { retVal = httpd_resp_send(req, jsonChar, strlen(jsonChar)); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } return retVal; diff --git a/code/components/gpio_ctrl/gpioPin.cpp b/code/components/gpio_ctrl/gpioPin.cpp index 7a2eb7241..a89281d5b 100644 --- a/code/components/gpio_ctrl/gpioPin.cpp +++ b/code/components/gpio_ctrl/gpioPin.cpp @@ -226,7 +226,7 @@ bool GpioPin::mqttPublishPinState(int _pwmDuty) if (jsonChar != NULL) { retVal &= MQTTPublish(mqttTopic + "/state", std::string(jsonChar), 1); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } if (!retVal) { diff --git a/code/components/mainprocess_ctrl/ClassFlowMQTT.cpp b/code/components/mainprocess_ctrl/ClassFlowMQTT.cpp index 0cd73505a..1544483e6 100644 --- a/code/components/mainprocess_ctrl/ClassFlowMQTT.cpp +++ b/code/components/mainprocess_ctrl/ClassFlowMQTT.cpp @@ -178,7 +178,7 @@ bool ClassFlowMQTT::doFlow(std::string zwtime) if (jsonChar != NULL) { retValData &= MQTTPublish(cfgDataPtr->mainTopic + "/process/data/" + std::to_string(sequence->sequenceId) + "/json", std::string(jsonChar), MQTT_QOS, cfgDataPtr->retainProcessData); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } } diff --git a/code/components/mainprocess_ctrl/ClassFlowWebhook.cpp b/code/components/mainprocess_ctrl/ClassFlowWebhook.cpp index 8dbc7800b..ba434924b 100644 --- a/code/components/mainprocess_ctrl/ClassFlowWebhook.cpp +++ b/code/components/mainprocess_ctrl/ClassFlowWebhook.cpp @@ -122,7 +122,7 @@ bool ClassFlowWebhook::doFlow(std::string zwtime) setFlowStateHandlerEvent(1); // Set warning event code, continue process flow } } - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } if (!getFlowState()->isSuccessful) diff --git a/code/components/mqtt_ctrl/server_mqtt.cpp b/code/components/mqtt_ctrl/server_mqtt.cpp index 2e15bbb75..8352351c4 100644 --- a/code/components/mqtt_ctrl/server_mqtt.cpp +++ b/code/components/mqtt_ctrl/server_mqtt.cpp @@ -104,7 +104,7 @@ bool mqttServer_publishDeviceInfo(int _qos) if (jsonChar != NULL) { retVal &= MQTTPublish(cfgDataPtr->mainTopic + deviceInfoTopic + "hardware", std::string(jsonChar), _qos, true); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); jsonChar = NULL; } @@ -128,7 +128,7 @@ bool mqttServer_publishDeviceInfo(int _qos) if (jsonChar != NULL) { retVal &= MQTTPublish(cfgDataPtr->mainTopic + deviceInfoTopic + "network", std::string(jsonChar), _qos, true); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); jsonChar = NULL; } @@ -194,7 +194,7 @@ bool mqttServer_publishDeviceStatus(int _qos) if (jsonChar != NULL) { retVal &= MQTTPublish(cfgDataPtr->mainTopic + deviceStatusTopic + "heap", std::string(jsonChar), _qos, false); - heap_caps_free(jsonChar); // Avoid using cJSON_Delete, because configClass using modified cJSON initHooks + cJSON_free(jsonChar); } retVal &= MQTTPublish(cfgDataPtr->mainTopic + deviceStatusTopic + "sd_partition_free", std::to_string(getSDCardFreePartitionSpace()), _qos, false);