From: <arc...@us...> - 2013-02-15 00:45:01
|
Revision: 641 http://sourceforge.net/p/sipp/code/641 Author: arcady-91 Date: 2013-02-15 00:44:58 +0000 (Fri, 15 Feb 2013) Log Message: ----------- Small fixes (various) Modified Paths: -------------- sipp/trunk/call.cpp sipp/trunk/sipp.cpp Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2013-02-15 00:44:53 UTC (rev 640) +++ sipp/trunk/call.cpp 2013-02-15 00:44:58 UTC (rev 641) @@ -44,13 +44,13 @@ #include <iostream> #include <sys/types.h> #include <sys/wait.h> +#include <assert.h> #ifdef PCAPPLAY #include "send_packets.h" #endif #include "sipp.hpp" #include "deadcall.hpp" -#include "assert.h" #define callDebug(args...) do { if (useCallDebugf) { _callDebug( args ); } } while (0) @@ -476,11 +476,7 @@ putUserVars = true; } if (call_scenario->allocVars->size > 0) { - if (userVars) { M_callVariableTable = new VariableTable(userVars, call_scenario->allocVars->size); - } else { - M_callVariableTable = new VariableTable(userVars, call_scenario->allocVars->size); - } } else if (userVars->size > 0) { M_callVariableTable = userVars->getTable(); } else if (globalVariables->size > 0) { @@ -1207,7 +1203,7 @@ } if(!(last_request_uri = (char *) malloc(tmp_len+1))) ERROR("Cannot allocate !\n"); - memset(last_request_uri, 0, sizeof(last_request_uri)); + memset(last_request_uri, 0, sizeof(*last_request_uri)); if(tmp && (tmp_len > 0)){ strncpy(last_request_uri, tmp, tmp_len); } Modified: sipp/trunk/sipp.cpp =================================================================== --- sipp/trunk/sipp.cpp 2013-02-15 00:44:53 UTC (rev 640) +++ sipp/trunk/sipp.cpp 2013-02-15 00:44:58 UTC (rev 641) @@ -911,7 +911,7 @@ if( creationMode == MODE_SERVER) { sprintf(temp_str, "%llu calls", display_scenario->stats->GetStat(CStat::CPT_C_CurrentCall)); } else { - sprintf(temp_str, "%llu calls (limit %d)", display_scenario->stats->GetStat(CStat::CPT_C_CurrentCall), open_calls_allowed); + sprintf(temp_str, "%llu calls (limit %u)", display_scenario->stats->GetStat(CStat::CPT_C_CurrentCall), open_calls_allowed); } fprintf(f," %-38s Peak was %llu calls, after %llu s" SIPP_ENDL, temp_str, @@ -1066,19 +1066,11 @@ fprintf(f, " "); } - if(curmsg->retrans_delay) { fprintf(f,"%-9ld %-9ld %-9ld %-9ld" , curmsg->nb_recv, curmsg->nb_recv_retrans, curmsg->nb_timeout, curmsg->nb_unexp); - } else { - fprintf(f,"%-9ld %-9ld %-9ld %-9ld" , - curmsg -> nb_recv, - curmsg -> nb_recv_retrans, - curmsg -> nb_timeout, - curmsg -> nb_unexp); - } } else if (curmsg -> pause_distribution || (curmsg -> pause_variable != -1)) { char *desc = curmsg->pause_desc; @@ -1196,9 +1188,9 @@ if(SendingMessage *src = curmsg -> send_scheme) { if(header) { if (src->isResponse()) { - sprintf(temp_str, "%d_%d_", index, src->getCode()); + sprintf(temp_str, "%u_%d_", index, src->getCode()); } else { - sprintf(temp_str, "%d_%s_", index, src->getMethod()); + sprintf(temp_str, "%u_%s_", index, src->getMethod()); } fprintf(f, "%sSent%s", temp_str, stat_delimiter); @@ -1263,7 +1255,7 @@ curmsg -> pause_variable) { if(header) { - sprintf(temp_str, "%d_Pause_", index); + sprintf(temp_str, "%u_Pause_", index); fprintf(f, "%sSessions%s", temp_str, stat_delimiter); fprintf(f, "%sUnexp%s", temp_str, stat_delimiter); } else { @@ -1274,7 +1266,7 @@ /* No output. */ } else if(curmsg -> M_type == MSG_TYPE_RECVCMD) { if(header) { - sprintf(temp_str, "%d_RecvCmd", index); + sprintf(temp_str, "%u_RecvCmd", index); fprintf(f, "%s%s", temp_str, stat_delimiter); fprintf(f, "%s_Timeout%s", temp_str, stat_delimiter); } else { @@ -1283,7 +1275,7 @@ } } else if(curmsg -> M_type == MSG_TYPE_SENDCMD) { if(header) { - sprintf(temp_str, "%d_SendCmd", index); + sprintf(temp_str, "%u_SendCmd", index); fprintf(f, "%s%s", temp_str, stat_delimiter); } else { fprintf(f, "%lu%s", curmsg->M_nbCmdSent, stat_delimiter); @@ -1378,10 +1370,9 @@ void print_tdm_map() { - int interval = 0; int i = 0; int in_use = 0; - interval = (tdm_map_a+1) * (tdm_map_b+1) * (tdm_map_c+1); + int interval = (tdm_map_a+1) * (tdm_map_b+1) * (tdm_map_c+1); printf("TDM Circuits in use:" SIPP_ENDL); while (i<interval) { @@ -1421,21 +1412,21 @@ switch(curmsg->M_type) { case MSG_TYPE_RECV: - printf("=> Message[%d] (Receive Message) - " + printf("=> Message[%u] (Receive Message) - " "[%d] action(s) defined :" SIPP_ENDL, i, actions->getActionSize()); printed++; break; case MSG_TYPE_RECVCMD: - printf("=> Message[%d] (Receive Command Message) - " + printf("=> Message[%u] (Receive Command Message) - " "[%d] action(s) defined :" SIPP_ENDL, i, actions->getActionSize()); printed++; break; default: - printf("=> Message[%d] - [%d] action(s) defined :" SIPP_ENDL, + printf("=> Message[%u] - [%d] action(s) defined :" SIPP_ENDL, i, actions->getActionSize()); printed++; @@ -2042,7 +2033,14 @@ } } else { int command_len = strlen(command_buffer); - command_buffer = (char *)realloc(command_buffer, command_len + 2); + char *realloc_ptr = (char *)realloc(command_buffer, command_len + 2); + if (realloc_ptr) { + command_buffer = realloc_ptr; + } else { + free(command_buffer); + ERROR("Out of memory"); + return; + } command_buffer[command_len++] = c; command_buffer[command_len] = '\0'; putchar(c); @@ -2050,7 +2048,14 @@ } } else if (c == 'c') { command_mode = 1; - command_buffer = (char *)realloc(command_buffer, 1); + char *realloc_ptr = (char *)realloc(command_buffer, 1); + if (realloc_ptr) { + command_buffer = realloc_ptr; + } else { + free(command_buffer); + ERROR("Out of memory"); + return; + } command_buffer[0] = '\0'; printf("Command: "); fflush(stdout); @@ -2121,11 +2126,9 @@ ptr ++; - while((*ptr) && - (*ptr != ' ') && + while((*ptr != ' ') && (*ptr != ';') && (*ptr != '\t') && - (*ptr != '\t') && (*ptr != '\r') && (*ptr != '\n') && (*ptr)) { @@ -3772,7 +3775,7 @@ /* Update the clock. */ getmilliseconds(); /* Receive incoming messages */ - pollset_process(running_tasks->size() == 0); + pollset_process(running_tasks->empty()); } } @@ -4151,9 +4154,7 @@ } static struct sipp_socket *sipp_allocate_socket(bool use_ipv6, int transport, int fd, int accepting) { - struct sipp_socket *ret = NULL; - - ret = (struct sipp_socket *)malloc(sizeof(struct sipp_socket)); + struct sipp_socket *ret = (struct sipp_socket *)malloc(sizeof(struct sipp_socket)); if (!ret) { ERROR("Could not allocate a sipp_socket structure."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |