X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketInterpreter.cc;h=cb94b8dfe2f855ba0b863c69809d4672e4fa7e98;hb=78a6e233083efa63a9cd0684a92abc64202a9ee7;hp=285ed9a5a2633e5d513135e677cdea4eabfaeb25;hpb=9cb871b939efe93e35dd96808d25089399acfc46;p=senf.git diff --git a/senf/Packets/PacketInterpreter.cc b/senf/Packets/PacketInterpreter.cc index 285ed9a..cb94b8d 100644 --- a/senf/Packets/PacketInterpreter.cc +++ b/senf/Packets/PacketInterpreter.cc @@ -75,7 +75,8 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr prefix_ void senf::PacketInterpreterBase::dump(std::ostream & os) { try { - if (detail::AnnotationIndexerBase::maxAnnotations > 0) { + if (detail::AnnotationRegistry::instance().begin() + != detail::AnnotationRegistry::instance().end()) { os << "Annotations:\n"; impl().dumpAnnotations(os); } @@ -100,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_ void 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