diff --git a/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.cpp index 669403ccc64e59870dce00adfa68626d0edb0a50..0f9905f0d2cf062f2e75c9f83265cb4d89857d8d 100644 --- a/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.cpp @@ -54,12 +54,16 @@ AudioSymmetricRtpSession::AudioSymmetricRtpSession (SIPCall * sipcall) : AudioSymmetricRtpSession::~AudioSymmetricRtpSession() { + // XXX: DON'T call any members of this (i.e. AudioSymmetricRtpSession and + // the classes from which it is derived, or touch any of their data _info ("AudioSymmetricRtpSession: Delete AudioSymmetricRtpSession instance"); } void AudioSymmetricRtpSession::final() { delete _rtpThread; + + // See: http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.15 delete this; } diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp index 8c4b23fba6736aed0516f08cc9a0c60210d7f139..91e44a92d27fc0dee23f12a632ffc21233032d47 100644 --- a/sflphone-common/src/sip/sdp.cpp +++ b/sflphone-common/src/sip/sdp.cpp @@ -648,6 +648,7 @@ Sdp::~Sdp() for (iter = localAudioMediaCap_.begin(); iter != localAudioMediaCap_.end(); ++iter) delete *iter; + pj_pool_release (memPool_); } diff --git a/sflphone-common/src/sip/sipcall.cpp b/sflphone-common/src/sip/sipcall.cpp index 6dd14092dea5e117136d581b483d421ebaf050ee..b577d77c6ef42760d9c18214d43da06ac8e31225 100644 --- a/sflphone-common/src/sip/sipcall.cpp +++ b/sflphone-common/src/sip/sipcall.cpp @@ -46,28 +46,18 @@ SIPCall::SIPCall (const std::string& id, Call::CallType type, pj_caching_pool *c , _audiortp (new sfl::AudioRtpFactory(this)) , _xferSub (NULL) , _invSession (NULL) - , _local_sdp (NULL) - , pool_(NULL) + , pool_(pj_pool_create(&caching_pool->factory, id.c_str(), CALL_MEMPOOL_INIT_SIZE, + CALL_MEMPOOL_INC_SIZE, NULL)) + , local_sdp_(pool_) { _debug ("SIPCall: Create new call %s", id.c_str()); - - // Create memory pool for application, initialization value is based on empiric values. - pool_ = pj_pool_create (&caching_pool->factory, id.c_str(), CALL_MEMPOOL_INIT_SIZE, - CALL_MEMPOOL_INC_SIZE, NULL); - - _local_sdp = new Sdp (pool_); } SIPCall::~SIPCall() { _debug ("SIPCall: Delete call"); - _debug ("SDP: pool capacity %d", pj_pool_get_capacity (pool_)); _debug ("SDP: pool size %d", pj_pool_get_used_size (pool_)); - pj_pool_release (pool_); - pool_ = 0; - // Release memory allocated for SDP - delete _local_sdp; delete _audiortp; } diff --git a/sflphone-common/src/sip/sipcall.h b/sflphone-common/src/sip/sipcall.h index 1d9366f95bcfd49287dbee06e283983e2d8eaa23..083cc6f386fc6478b7df0bf0ab9eddbbb1bce437 100644 --- a/sflphone-common/src/sip/sipcall.h +++ b/sflphone-common/src/sip/sipcall.h @@ -33,9 +33,9 @@ #define SIPCALL_H #include "call.h" +#include "sdp.h" #include <cassert> -class Sdp; class pjsip_evsub; class pj_caching_pool; class pj_pool_t; @@ -96,7 +96,7 @@ class SIPCall : public Call * Return the local SDP session */ Sdp* getLocalSDP (void) { - return _local_sdp; + return &local_sdp_; } /** @@ -110,7 +110,6 @@ class SIPCall : public Call * Return the local memory pool for this call */ pj_pool_t *getMemoryPool(void) { - assert(pool_); return pool_; } @@ -162,16 +161,15 @@ class SIPCall : public Call */ pjsip_inv_session *_invSession; - /** - * The SDP session - */ - Sdp *_local_sdp; - /** * The pool to allocate memory, released once call hang up */ pj_pool_t *pool_; + /** + * The SDP session + */ + Sdp local_sdp_; }; #endif