From: Caisking Date: Tue, 17 Mar 2026 07:36:55 +0000 (+0800) Subject: 优化文件传输的内存泄漏 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=293aaaf8d64ecf54b3e6cfbaf570305f9735dc8b;p=mirrors%2FFD230.git 优化文件传输的内存泄漏 --- diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp index 4af3948cd..22d82adaf 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp @@ -893,9 +893,10 @@ char * tar_dir_to_json_buf_malloc_(char* file_name,uint32_t *file_size) char *json_format = cJSON_PrintUnformatted(itemJSON); - int pSize = cJSON_GetArraySize(dataJSON); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + cJSON_Delete(itemJSON); cJSON_Delete(dataJSON); + cJSON_Delete(data_arryJSON); file_index++; return json_format; diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp index 839fd53a2..3399cf26b 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp @@ -1891,9 +1891,10 @@ char * tar_dir_to_json_buf_malloc_(char* file_name,uint32_t *file_size) char *json_format = cJSON_PrintUnformatted(itemJSON); - int pSize = cJSON_GetArraySize(dataJSON); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + cJSON_Delete(itemJSON); cJSON_Delete(dataJSON); + cJSON_Delete(data_arryJSON); file_index++; return json_format; @@ -3602,9 +3603,10 @@ char * tar_dir_to_json_buf_malloc_(char* file_name,uint32_t *file_size) char *json_format = cJSON_PrintUnformatted(itemJSON); - int pSize = cJSON_GetArraySize(dataJSON); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"文件数据:%s\r\n",json_format); + cJSON_Delete(itemJSON); cJSON_Delete(dataJSON); + cJSON_Delete(data_arryJSON); file_index++; return json_format; @@ -3626,6 +3628,8 @@ char * tar_dir_to_json_buf_malloc_(char* file_name,uint32_t *file_size) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"opendir fail\r\n"); } + cJSON_Delete(dataJSON); + cJSON_Delete(data_arryJSON); return NULL; }