some memory usage cleanup based on valgrind report
This commit is contained in:
parent
f4e1c1d4a4
commit
dfb2d9d470
@ -481,16 +481,17 @@ char *
|
|||||||
iperf_reporter_callback(struct iperf_test * test)
|
iperf_reporter_callback(struct iperf_test * test)
|
||||||
{
|
{
|
||||||
int total_packets = 0, lost_packets = 0, curr_state = 0;
|
int total_packets = 0, lost_packets = 0, curr_state = 0;
|
||||||
|
char *message = NULL;
|
||||||
|
char *message_final = NULL;
|
||||||
char ubuf[UNIT_LEN];
|
char ubuf[UNIT_LEN];
|
||||||
char nbuf[UNIT_LEN];
|
char nbuf[UNIT_LEN];
|
||||||
struct iperf_stream *sp = NULL;
|
struct iperf_stream *sp = NULL;
|
||||||
iperf_size_t bytes = 0;
|
iperf_size_t bytes = 0;
|
||||||
double start_time, end_time;
|
double start_time, end_time;
|
||||||
struct iperf_interval_results *ip = NULL;
|
struct iperf_interval_results *ip = NULL;
|
||||||
char *message = (char *) malloc(MAX_RESULT_STRING);
|
|
||||||
char *message_final = (char *) malloc(MAX_RESULT_STRING);
|
|
||||||
|
|
||||||
memset(message_final, 0, strlen(message_final));
|
message = (char *)calloc(MAX_RESULT_STRING, sizeof(char));
|
||||||
|
message_final = (char *)calloc(MAX_RESULT_STRING, sizeof(char));
|
||||||
|
|
||||||
sp = test->streams;
|
sp = test->streams;
|
||||||
curr_state = sp->settings->state;
|
curr_state = sp->settings->state;
|
||||||
@ -570,7 +571,7 @@ iperf_reporter_callback(struct iperf_test * test)
|
|||||||
#if defined(linux) || defined(__FreeBSD__)
|
#if defined(linux) || defined(__FreeBSD__)
|
||||||
if (test->tcp_info)
|
if (test->tcp_info)
|
||||||
{
|
{
|
||||||
printf("Final TCP_INFO results: \n");
|
//printf("Final TCP_INFO results: \n");
|
||||||
ip = sp->result->last_interval_results;
|
ip = sp->result->last_interval_results;
|
||||||
build_tcpinfo_message(ip, message);
|
build_tcpinfo_message(ip, message);
|
||||||
safe_strcat(message_final, message);
|
safe_strcat(message_final, message);
|
||||||
|
@ -56,7 +56,7 @@ int
|
|||||||
param_received(struct iperf_stream * sp, struct param_exchange * param)
|
param_received(struct iperf_stream * sp, struct param_exchange * param)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char *buf = (char *) malloc(sizeof(struct param_exchange));
|
char *buf = (char *) calloc(1, sizeof(struct param_exchange));
|
||||||
|
|
||||||
if (sp->settings->cookie[0] == '\0' ||
|
if (sp->settings->cookie[0] == '\0' ||
|
||||||
(strncmp(param->cookie, sp->settings->cookie, COOKIE_SIZE) == 0))
|
(strncmp(param->cookie, sp->settings->cookie, COOKIE_SIZE) == 0))
|
||||||
|
@ -232,11 +232,11 @@ const char reportCSV_peer[] =
|
|||||||
|
|
||||||
#if defined(linux)
|
#if defined(linux)
|
||||||
const char report_tcpInfo[] =
|
const char report_tcpInfo[] =
|
||||||
"event=TCP_Info CWND=%u SND_SSTHRESH=%u RCV_SSTHRESH=%u UNACKED=%u SACK=%u LOST=%u RETRANS=%u FACK=%u RTT=%u REORDERING=%u";
|
"event=TCP_Info CWND=%u SND_SSTHRESH=%u RCV_SSTHRESH=%u UNACKED=%u SACK=%u LOST=%u RETRANS=%u FACK=%u RTT=%u REORDERING=%u\n";
|
||||||
#endif
|
#endif
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
const char report_tcpInfo[] =
|
const char report_tcpInfo[] =
|
||||||
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u";
|
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ print_tcpinfo(struct iperf_interval_results *r)
|
|||||||
void
|
void
|
||||||
build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
||||||
{
|
{
|
||||||
printf("in build_tcpinfo_message \n");
|
|
||||||
#if defined(linux)
|
#if defined(linux)
|
||||||
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_snd_ssthresh,
|
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_snd_ssthresh,
|
||||||
r->tcpInfo.tcpi_rcv_ssthresh, r->tcpInfo.tcpi_unacked, r->tcpInfo.tcpi_sacked,
|
r->tcpInfo.tcpi_rcv_ssthresh, r->tcpInfo.tcpi_unacked, r->tcpInfo.tcpi_sacked,
|
||||||
|
@ -65,7 +65,6 @@ update_timer(struct timer * tp, time_t sec, suseconds_t usec)
|
|||||||
{
|
{
|
||||||
perror("gettimeofday");
|
perror("gettimeofday");
|
||||||
}
|
}
|
||||||
memcpy(&tp->end, &tp->begin, sizeof(struct timer));
|
|
||||||
tp->end.tv_sec = tp->begin.tv_sec + (time_t) sec;
|
tp->end.tv_sec = tp->begin.tv_sec + (time_t) sec;
|
||||||
tp->end.tv_usec = tp->begin.tv_usec + (time_t) usec;
|
tp->end.tv_usec = tp->begin.tv_usec + (time_t) usec;
|
||||||
|
|
||||||
@ -75,8 +74,8 @@ update_timer(struct timer * tp, time_t sec, suseconds_t usec)
|
|||||||
struct timer *
|
struct timer *
|
||||||
new_timer(time_t sec, suseconds_t usec)
|
new_timer(time_t sec, suseconds_t usec)
|
||||||
{
|
{
|
||||||
struct timer *tp;
|
struct timer *tp = NULL;
|
||||||
tp = (struct timer *) malloc(sizeof(struct timer));
|
tp = (struct timer *) calloc(1, sizeof(struct timer));
|
||||||
if (tp == NULL)
|
if (tp == NULL)
|
||||||
{
|
{
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
@ -88,7 +87,7 @@ new_timer(time_t sec, suseconds_t usec)
|
|||||||
perror("gettimeofday");
|
perror("gettimeofday");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(&tp->end, &tp->begin, sizeof(struct timer));
|
|
||||||
tp->end.tv_sec = tp->begin.tv_sec + (time_t) sec;
|
tp->end.tv_sec = tp->begin.tv_sec + (time_t) sec;
|
||||||
tp->end.tv_usec = tp->begin.tv_usec + (time_t) usec;
|
tp->end.tv_usec = tp->begin.tv_usec + (time_t) usec;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user