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

[reSIProcate] SipStack::send: clone vs new


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