Skip to content

Commit

Permalink
Merge pull request SIPp#704 from orgads/nullptr
Browse files Browse the repository at this point in the history
Replace NULL with nullptr
  • Loading branch information
orgads authored Apr 1, 2024
2 parents 1715a68 + 82b3926 commit ab788f5
Show file tree
Hide file tree
Showing 29 changed files with 598 additions and 599 deletions.
6 changes: 3 additions & 3 deletions include/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class call : virtual public task, virtual public listener, public virtual socket

virtual ~call();

virtual bool process_incoming(const char* msg, const struct sockaddr_storage* src = NULL);
virtual bool process_incoming(const char* msg, const struct sockaddr_storage* src = nullptr);
virtual bool process_twinSippCom(char* msg);

virtual bool run();
Expand Down Expand Up @@ -273,9 +273,9 @@ class call : virtual public task, virtual public listener, public virtual socket
double get_rhs(CAction *currentAction);

// P_index use for message index in scenario
char* createSendingMessage(SendingMessage* src, int P_index=-1, int *msgLen=NULL);
char* createSendingMessage(SendingMessage* src, int P_index=-1, int *msgLen=nullptr);
char* createSendingMessage(char* src, int P_index, bool skip_sanity=false);
char* createSendingMessage(SendingMessage*src, int P_index, char *msg_buffer, int buflen, int *msgLen=NULL);
char* createSendingMessage(SendingMessage*src, int P_index, char *msg_buffer, int buflen, int *msgLen=nullptr);

// method for the management of unexpected messages
bool checkInternalCmd(char* cmd); // check of specific internal command
Expand Down
2 changes: 1 addition & 1 deletion include/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void log_off(struct logfile_info *lfi);

#ifdef GLOBALS_FULL_DEFINITION
#define LOGFILE(name, s, check) \
struct logfile_info name = { s, check, NULL, 0, NULL, "", true, false, 0, 0 }
struct logfile_info name = { s, check, nullptr, 0, nullptr, "", true, false, 0, 0 }
#else
#define LOGFILE(name, s, check) \
extern struct logfile_info name
Expand Down
24 changes: 12 additions & 12 deletions include/sipp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,24 +323,24 @@ MAYBE_EXTERN double tls_version DEFVAL(0.0);
#endif

#ifdef SO_BINDTODEVICE
MAYBE_EXTERN const char * bind_to_device_name DEFVAL(NULL);
MAYBE_EXTERN const char * bind_to_device_name DEFVAL(nullptr);
#endif

MAYBE_EXTERN char* scenario_file DEFVAL(NULL);
MAYBE_EXTERN char* scenario_path DEFVAL(NULL);
MAYBE_EXTERN char* scenario_file DEFVAL(nullptr);
MAYBE_EXTERN char* scenario_path DEFVAL(nullptr);

// extern field file management
typedef std::map<std::string, FileContents *> file_map;
MAYBE_EXTERN file_map inFiles;
typedef std::map<std::string, str_int_map *> file_index;
MAYBE_EXTERN char *ip_file DEFVAL(NULL);
MAYBE_EXTERN char *default_file DEFVAL(NULL);
MAYBE_EXTERN char *ip_file DEFVAL(nullptr);
MAYBE_EXTERN char *default_file DEFVAL(nullptr);

// free user id list
MAYBE_EXTERN std::list<int> freeUsers;
MAYBE_EXTERN std::list<int> retiredUsers;
MAYBE_EXTERN AllocVariableTable *globalVariables DEFVAL(NULL);
MAYBE_EXTERN AllocVariableTable *userVariables DEFVAL(NULL);
MAYBE_EXTERN AllocVariableTable *globalVariables DEFVAL(nullptr);
MAYBE_EXTERN AllocVariableTable *userVariables DEFVAL(nullptr);
typedef std::map<int, VariableTable *> int_vt_map;
MAYBE_EXTERN int_vt_map userVarMap;

Expand Down Expand Up @@ -415,9 +415,9 @@ MAYBE_EXTERN int stepDynamicId DEFVAL(4); // step of increment for dynam

/*********************** Global Sockets **********************/

MAYBE_EXTERN SIPpSocket *main_socket DEFVAL(NULL);
MAYBE_EXTERN SIPpSocket *main_remote_socket DEFVAL(NULL);
MAYBE_EXTERN SIPpSocket *tcp_multiplex DEFVAL(NULL);
MAYBE_EXTERN SIPpSocket *main_socket DEFVAL(nullptr);
MAYBE_EXTERN SIPpSocket *main_remote_socket DEFVAL(nullptr);
MAYBE_EXTERN SIPpSocket *tcp_multiplex DEFVAL(nullptr);
MAYBE_EXTERN int media_socket_audio DEFVAL(0);
MAYBE_EXTERN int media_socket_video DEFVAL(0);

Expand All @@ -435,8 +435,8 @@ MAYBE_EXTERN std::set<SIPpSocket*> sockets_pending_reset;

MAYBE_EXTERN struct sockaddr_storage local_addr_storage;

MAYBE_EXTERN SIPpSocket *twinSippSocket DEFVAL(NULL);
MAYBE_EXTERN SIPpSocket *localTwinSippSocket DEFVAL(NULL);
MAYBE_EXTERN SIPpSocket *twinSippSocket DEFVAL(nullptr);
MAYBE_EXTERN SIPpSocket *localTwinSippSocket DEFVAL(nullptr);
MAYBE_EXTERN struct sockaddr_storage twinSipp_sockaddr;

/* 3pcc extended mode */
Expand Down
2 changes: 1 addition & 1 deletion include/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SIPpSocket {
static SIPpSocket* new_sipp_call_socket(bool use_ipv6, int transport, bool *existing);
void set_bind_port(int bind_port);

int connect(struct sockaddr_storage* dest = NULL);
int connect(struct sockaddr_storage* dest = nullptr);
int reconnect();

// Reset a failed connection
Expand Down
90 changes: 45 additions & 45 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ int* CAction::getSubVarId()
void CAction::setNbSubVarId (int P_value)
{
M_maxNbSubVarId = P_value;
if (M_subVarId != NULL) {
if (M_subVarId != nullptr) {
delete [] M_subVarId;
M_subVarId = NULL;
M_subVarId = nullptr;
}
M_subVarId = new int[M_maxNbSubVarId] ;
M_nbSubVarId = 0 ;
Expand All @@ -411,27 +411,27 @@ int CAction::getNbSubVarId ()

void CAction::setLookingChar(const char* P_value)
{
if (M_lookingChar != NULL) {
if (M_lookingChar != nullptr) {
delete [] M_lookingChar;
M_lookingChar = NULL;
M_lookingChar = nullptr;
}

if (P_value != NULL) {
if (P_value != nullptr) {
M_lookingChar = new char[strlen(P_value)+1];
strcpy(M_lookingChar, P_value);
}
}

void CAction::setMessage(const char* P_value, int n)
{
if (M_message[n] != NULL) {
if (M_message[n] != nullptr) {
delete M_message[n];
M_message[n] = NULL;
M_message[n] = nullptr;
}
free(M_message_str[n]);
M_message_str[n] = NULL;
M_message_str[n] = nullptr;

if (P_value != NULL) {
if (P_value != nullptr) {
M_message_str[n] = strdup(P_value);
M_message[n] = new SendingMessage(M_scenario, P_value, true /* skip sanity */);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ int CAction::executeRegExp(const char* P_string, VariableTable *P_callVarTable)
regmatch_t pmatch[10];
int error;
int nbOfMatch = 0;
char* result = NULL ;
char* result = nullptr ;

if (!M_regExpSet) {
ERROR("Trying to perform regular expression match on action that does not have one!");
Expand Down Expand Up @@ -501,7 +501,7 @@ void CAction::setSubString(char** P_target, const char* P_source, int P_start, i
{
int sizeOf;

if (P_source != NULL) {
if (P_source != nullptr) {
sizeOf = P_stop - P_start;
(*P_target) = new char[sizeOf + 1];

Expand All @@ -511,33 +511,33 @@ void CAction::setSubString(char** P_target, const char* P_source, int P_start, i

(*P_target)[sizeOf] = '\0';
} else {
*P_target = NULL ;
*P_target = nullptr ;
}
}


#ifdef PCAPPLAY
void CAction::setPcapArgs (pcap_pkts * P_value)
{
if (M_pcapArgs != NULL) {
if (M_pcapArgs != nullptr) {
free(M_pcapArgs);
M_pcapArgs = NULL;
M_pcapArgs = nullptr;
}

if (P_value != NULL) {
if (P_value != nullptr) {
M_pcapArgs = (pcap_pkts *)malloc(sizeof(*M_pcapArgs));
memcpy(M_pcapArgs, P_value, sizeof(*M_pcapArgs));
}
}

void CAction::setPcapArgs(const char* P_value)
{
if (M_pcapArgs != NULL) {
if (M_pcapArgs != nullptr) {
free(M_pcapArgs);
M_pcapArgs = NULL;
M_pcapArgs = nullptr;
}

if (P_value != NULL) {
if (P_value != nullptr) {
M_pcapArgs = (pcap_pkts *) malloc(sizeof(*M_pcapArgs));
if (parse_play_args(P_value, M_pcapArgs) == -1) {
ERROR("Play pcap error");
Expand Down Expand Up @@ -570,7 +570,7 @@ void CAction::setRTPEchoActInfo(const char* P_value)

strcpy (actionstring,P_value);
param_str = strchr(actionstring,',');
next_comma = NULL;
next_comma = nullptr;

// Comma found for payload_type parameter
if (param_str) {
Expand Down Expand Up @@ -907,7 +907,7 @@ void CAction::setScenario(scenario * P_scenario)
void CAction::setAction(CAction P_action)
{
if (P_action.getActionType() == CAction::E_AT_ASSIGN_FROM_SAMPLE) {
assert(P_action.getDistribution() != NULL);
assert(P_action.getDistribution() != nullptr);
}
int L_i;
setActionType ( P_action.getActionType() );
Expand Down Expand Up @@ -950,58 +950,58 @@ CAction::CAction(scenario *scenario)

M_nbSubVarId = 0;
M_maxNbSubVarId = 0;
M_subVarId = NULL;
M_subVarId = nullptr;

M_checkIt = false;
M_checkItInverse = false;
M_lookingPlace = E_LP_MSG;
M_lookingChar = NULL;
M_lookingChar = nullptr;
M_caseIndep = false;
M_occurrence = 1;
M_headersOnly = true;
for (int i = 0; i < MAX_ACTION_MESSAGE; i++) {
M_message[i] = NULL;
M_message_str[i] = NULL;
M_message[i] = nullptr;
M_message_str[i] = nullptr;
}
M_IntCmd = E_INTCMD_INVALID;
M_doubleValue = 0;
M_stringValue = NULL;
M_distribution = NULL;
M_stringValue = nullptr;
M_distribution = nullptr;
#ifdef PCAPPLAY
M_pcapArgs = NULL;
M_pcapArgs = nullptr;
#endif

memset(&M_rtpecho_actinfo, 0, sizeof(M_rtpecho_actinfo));
memset(&M_rtpstream_actinfo, 0, sizeof(M_rtpstream_actinfo));

M_scenario = scenario;
M_regExpSet = false;
M_regularExpression = NULL;
M_regularExpression = nullptr;
}

CAction::~CAction()
{
if (M_lookingChar != NULL) {
if (M_lookingChar != nullptr) {
delete [] M_lookingChar;
M_lookingChar = NULL;
M_lookingChar = nullptr;
}
for (int i = 0; i < MAX_ACTION_MESSAGE; i++) {
if (M_message[i] != NULL) {
if (M_message[i] != nullptr) {
delete M_message[i];
M_message[i] = NULL;
M_message[i] = nullptr;
}
free(M_message_str[i]);
M_message_str[i] = NULL;
M_message_str[i] = nullptr;
}
if (M_subVarId != NULL) {
if (M_subVarId != nullptr) {
delete [] M_subVarId;
M_subVarId = NULL;
M_subVarId = nullptr;
}
free(M_stringValue);
#ifdef PCAPPLAY
if (M_pcapArgs != NULL) {
if (M_pcapArgs != nullptr) {
free_pcaps(M_pcapArgs);
M_pcapArgs = NULL;
M_pcapArgs = nullptr;
}
#endif
if (M_regExpSet) {
Expand Down Expand Up @@ -1030,7 +1030,7 @@ void CActions::reset()
{
for (int i = 0; i < M_nbAction; i++) {
delete M_actionList[i];
M_actionList[i] = NULL;
M_actionList[i] = nullptr;
}
M_nbAction = 0;
}
Expand Down Expand Up @@ -1062,14 +1062,14 @@ CAction* CActions::getAction(int i)
if (i < M_nbAction) {
return(M_actionList[i]);
} else
return(NULL);
return(nullptr);
}


CActions::CActions()
{
M_nbAction = 0;
M_actionList = NULL;
M_actionList = nullptr;
}


Expand All @@ -1079,20 +1079,20 @@ CActions::~CActions()
delete M_actionList[i];
}
delete [] M_actionList;
M_actionList = NULL;
M_actionList = nullptr;
}

#ifdef GTEST
#include "gtest/gtest.h"

TEST(actions, MatchingRegexp) {
AllocVariableTable vt(NULL);
AllocVariableTable vt(nullptr);
int id = vt.find("1", true);
int sub1_id = vt.find("2", true);
int sub2_id = vt.find("3", true);
int sub3_id = vt.find("4", true);
int sub4_id = vt.find("5", true);
CAction re(NULL);
CAction re(nullptr);
re.setVarId(id);
re.setNbSubVarId(4);
re.setSubVarId(sub1_id);
Expand All @@ -1111,13 +1111,13 @@ TEST(actions, MatchingRegexp) {
}

TEST(actions, NonMatchingRegexp) {
AllocVariableTable vt(NULL);
AllocVariableTable vt(nullptr);
int id = vt.find("1", true);
int sub1_id = vt.find("2", true);
int sub2_id = vt.find("3", true);
int sub3_id = vt.find("4", true);
int sub4_id = vt.find("5", true);
CAction re(NULL);
CAction re(nullptr);
re.setVarId(id);
re.setNbSubVarId(4);
re.setSubVarId(sub1_id);
Expand Down
Loading

0 comments on commit ab788f5

Please sign in to comment.