Skip to content

Commit

Permalink
Revert heap_caps_free to cJSON_free
Browse files Browse the repository at this point in the history
  • Loading branch information
Slider0007 committed Nov 3, 2024
1 parent 1fd286a commit b587d0a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions code/components/fileserver_ota/server_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/components/gpio_ctrl/gpioPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion code/components/mainprocess_ctrl/ClassFlowMQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/components/mainprocess_ctrl/ClassFlowWebhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions code/components/mqtt_ctrl/server_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

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

0 comments on commit b587d0a

Please sign in to comment.