Skip to content
Snippets Groups Projects
Commit d8864d3b authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6596: create local SDP on the stack, not the heap

parent 2326adc6
No related branches found
No related tags found
No related merge requests found
...@@ -54,12 +54,16 @@ AudioSymmetricRtpSession::AudioSymmetricRtpSession (SIPCall * sipcall) : ...@@ -54,12 +54,16 @@ AudioSymmetricRtpSession::AudioSymmetricRtpSession (SIPCall * sipcall) :
AudioSymmetricRtpSession::~AudioSymmetricRtpSession() 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"); _info ("AudioSymmetricRtpSession: Delete AudioSymmetricRtpSession instance");
} }
void AudioSymmetricRtpSession::final() void AudioSymmetricRtpSession::final()
{ {
delete _rtpThread; delete _rtpThread;
// See: http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.15
delete this; delete this;
} }
......
...@@ -648,6 +648,7 @@ Sdp::~Sdp() ...@@ -648,6 +648,7 @@ Sdp::~Sdp()
for (iter = localAudioMediaCap_.begin(); iter != localAudioMediaCap_.end(); ++iter) for (iter = localAudioMediaCap_.begin(); iter != localAudioMediaCap_.end(); ++iter)
delete *iter; delete *iter;
pj_pool_release (memPool_);
} }
......
...@@ -46,28 +46,18 @@ SIPCall::SIPCall (const std::string& id, Call::CallType type, pj_caching_pool *c ...@@ -46,28 +46,18 @@ SIPCall::SIPCall (const std::string& id, Call::CallType type, pj_caching_pool *c
, _audiortp (new sfl::AudioRtpFactory(this)) , _audiortp (new sfl::AudioRtpFactory(this))
, _xferSub (NULL) , _xferSub (NULL)
, _invSession (NULL) , _invSession (NULL)
, _local_sdp (NULL) , pool_(pj_pool_create(&caching_pool->factory, id.c_str(), CALL_MEMPOOL_INIT_SIZE,
, pool_(NULL) CALL_MEMPOOL_INC_SIZE, NULL))
, local_sdp_(pool_)
{ {
_debug ("SIPCall: Create new call %s", id.c_str()); _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() SIPCall::~SIPCall()
{ {
_debug ("SIPCall: Delete call"); _debug ("SIPCall: Delete call");
_debug ("SDP: pool capacity %d", pj_pool_get_capacity (pool_)); _debug ("SDP: pool capacity %d", pj_pool_get_capacity (pool_));
_debug ("SDP: pool size %d", pj_pool_get_used_size (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; delete _audiortp;
} }
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#define SIPCALL_H #define SIPCALL_H
#include "call.h" #include "call.h"
#include "sdp.h"
#include <cassert> #include <cassert>
class Sdp;
class pjsip_evsub; class pjsip_evsub;
class pj_caching_pool; class pj_caching_pool;
class pj_pool_t; class pj_pool_t;
...@@ -96,7 +96,7 @@ class SIPCall : public Call ...@@ -96,7 +96,7 @@ class SIPCall : public Call
* Return the local SDP session * Return the local SDP session
*/ */
Sdp* getLocalSDP (void) { Sdp* getLocalSDP (void) {
return _local_sdp; return &local_sdp_;
} }
/** /**
...@@ -110,7 +110,6 @@ class SIPCall : public Call ...@@ -110,7 +110,6 @@ class SIPCall : public Call
* Return the local memory pool for this call * Return the local memory pool for this call
*/ */
pj_pool_t *getMemoryPool(void) { pj_pool_t *getMemoryPool(void) {
assert(pool_);
return pool_; return pool_;
} }
...@@ -162,16 +161,15 @@ class SIPCall : public Call ...@@ -162,16 +161,15 @@ class SIPCall : public Call
*/ */
pjsip_inv_session *_invSession; pjsip_inv_session *_invSession;
/**
* The SDP session
*/
Sdp *_local_sdp;
/** /**
* The pool to allocate memory, released once call hang up * The pool to allocate memory, released once call hang up
*/ */
pj_pool_t *pool_; pj_pool_t *pool_;
/**
* The SDP session
*/
Sdp local_sdp_;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment