From ff5a8f9445a0b3f8c150cb988f90b6b239c38b62 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <le.businessman@gmail.com> Date: Sun, 25 Mar 2012 12:29:05 -0400 Subject: [PATCH] * #9509: use vector for credential info --- daemon/src/sip/sipaccount.cpp | 11 ++--------- daemon/src/sip/sipaccount.h | 11 +++-------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 01d8427ef1..72e832f85c 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -66,7 +66,7 @@ SIPAccount::SIPAccount(const std::string& accountID) , serviceRoute_() , tlsListenerPort_(DEFAULT_SIP_TLS_PORT) , transportType_(PJSIP_TRANSPORT_UNSPECIFIED) - , cred_(NULL) + , cred_() , tlsSetting_() , contactHeader_() , contactUpdateEnabled_(false) @@ -101,11 +101,6 @@ SIPAccount::SIPAccount(const std::string& accountID) , link_(SIPVoIPLink::instance()) {} -SIPAccount::~SIPAccount() -{ - delete [] cred_; -} - void SIPAccount::serialize(Conf::YamlEmitter *emitter) { using namespace Conf; @@ -927,11 +922,9 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str } // Create the credential array - delete[] cred_; - cred_ = new pjsip_cred_info[credentials_.size()]; + cred_.resize(credentials_.size()); size_t i = 0; - for (vector<map<string, string > >::const_iterator iter = credentials_.begin(); iter != credentials_.end(); ++iter) { map<string, string>::const_iterator val = (*iter).find(CONFIG_ACCOUNT_PASSWORD); diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index 7f2596db83..2b9a408728 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -110,11 +110,6 @@ class SIPAccount : public Account { */ SIPAccount(const std::string& accountID); - /** - * Virtual destructor - */ - virtual ~SIPAccount(); - virtual VoIPLink* getVoIPLink(); std::string getUserAgentName() const; @@ -196,8 +191,8 @@ class SIPAccount : public Account { void stopKeepAliveTimer(); - pjsip_cred_info *getCredInfo() const { - return cred_; + const pjsip_cred_info* getCredInfo() const { + return &(*cred_.begin()); } /** @@ -605,7 +600,7 @@ class SIPAccount : public Account { /** * Credential information stored for further registration. */ - pjsip_cred_info *cred_; + std::vector<pjsip_cred_info> cred_; /** * The TLS settings, used only if tls is chosen as a sip transport. -- GitLab