< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] SipStack::send: clone vs new


Thanks Kennard!  I agree with your analysis - using clone is definitely more flexible.  I'll also change from dynamic_cast to static_cast.

Scott

On Wed, Nov 3, 2010 at 1:14 AM, Kennard White <kennard_white@xxxxxxxxxxxx> wrote:
Hi,

I found an inconsistency between the various flavors of SipStack:send(). Hoping someone can explain...

The method SipStack::send(const SipMessage&msg, TransactionUser* tu) calls:
    new SipMessage(msg)

while the corresponding sendTo(..., const Tuple&, ...) method calls:
    dynamic_cast<SipMessage*>(msg.clone())

Seems like the 2nd method should be used everywhere so that the class of the SipMessage is preserved. In particular, to preserve the subclassed KeepAliveMessage. When duplicated via new(), the class is lost and the special encoder method is lost.

Looking at the above, why is dynamic_cast used? The result isn't NULL checked, so might as well use static_cast I would think. Not sure what I'm missing.

Thanks,
Kennard



_______________________________________________
resiprocate-devel mailing list
resiprocate-devel@xxxxxxxxxxxxxxx
https://list.resiprocate.org/mailman/listinfo/resiprocate-devel