X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketInterpreter.cc;h=77627d3ab5a594c293860023d02c1a0eff514d52;hb=720400ed1b874ea96481a29f0812145bb2785d40;hp=62b912c7ffed0bb7f1d2cb18e76d8eea0631d881;hpb=20c3dbf64b3beed10655dceaee5791680fb25383;p=senf.git diff --git a/senf/Packets/PacketInterpreter.cc b/senf/Packets/PacketInterpreter.cc index 62b912c..77627d3 100644 --- a/senf/Packets/PacketInterpreter.cc +++ b/senf/Packets/PacketInterpreter.cc @@ -101,6 +101,24 @@ prefix_ void senf::PacketInterpreterBase::finalizeTo(ptr other) finalizeThis(); } +// reference/memory management + +prefix_ void senf::PacketInterpreterBase::add_ref() +{ + if (impl_ && !refcount()) + impl_->add_ref(); + intrusive_refcount_t::add_ref(); +} + +prefix_ bool senf::PacketInterpreterBase::release() +{ + if (impl_ && refcount()==1) + // This call will set impl_ to 0 if we just removed the last reference ... + impl_->release(); + if (intrusive_refcount_t::release() && !impl_) + delete this; +} + /////////////////////////////////////////////////////////////////////////// // senf::PacketInterpreterBase::Factory