From 5b9a8da5ba6b8ecea1f589487a4a736b24e25979 Mon Sep 17 00:00:00 2001 From: wangyouzhan Date: Mon, 29 Jul 2019 13:52:09 +0800 Subject: 修改内存泄漏 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comm_audit.cpp | 85 ++++++++++++++++-------------------------------------- 1 file changed, 25 insertions(+), 60 deletions(-) diff --git a/src/comm_audit.cpp b/src/comm_audit.cpp index 5ffaa05..e570a70 100644 --- a/src/comm_audit.cpp +++ b/src/comm_audit.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "project_requirement.h" @@ -93,8 +94,8 @@ int get_ip_coun(char * filename, char *ip_address, char ** name_en) if (entry_data.has_data) { - *name_en = (char *)malloc(sizeof(entry_data.data_size + 1)); - memset(*name_en, '\0', sizeof(entry_data.data_size + 1)); + *name_en = (char *)malloc(entry_data.data_size + 1); + memset(*name_en, '\0', (entry_data.data_size + 1)); memcpy(*name_en, entry_data.utf8_string, entry_data.data_size); //printf ("%s\n", name_en); } @@ -268,13 +269,6 @@ void iterate_cb(const uchar * key, uint size, void * data, void *arg) char writefile[50]; writefile[0]='\0'; - // string write_path = g_comm_prog_configure.upload_log_path; - // if (write_path[write_path.size() - 1] != '/') - // write_path+='/'; - // #ifdef LOG_DEBUG - // cout<<"write_path:"<= g_comm_prog_configure.write_interval * 100) { - /* - char cmd[200] = {0}; - string log_path = g_comm_prog_configure.upload_log_path; - if (log_path[log_path.size() - 1] != '/') - log_path+='/'; -#ifdef LOG_DEBUG -cout<<"log_path:"<type == STREAM_TYPE_TCP) @@ -711,7 +677,6 @@ char COMM_AUDIT_ENTRY(struct streaminfo *a_stream, void **pme, int thread_seq, v ret = APP_STATE_DROPME; break; } - return ret; } -- cgit v1.2.3