mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Add and use new IntrusivePt type in Zeek
Manual memory management via Ref/Unref is verbose and prone to error. An intrusive smart pointer automates the reference counting, makes code more robust (in particular w.r.t. to exceptions) and reduces boilerplate code. A big benefit of the intrusive smart pointers for Zeek is that they can co-exist with the manual memory management. Rather than having to port the entire code base at once, we can migrate components one-by-one. In this first step, we add the new template `IntrusivePtr<T>` and start using it in the Broker Manager. This makes the previous `unref_guard` obsolete.
This commit is contained in:
parent
0ab72e5983
commit
0f41b063b2
8 changed files with 259 additions and 60 deletions
|
@ -403,14 +403,14 @@ std::pair<bool, Frame*> Frame::Unserialize(const broker::vector& data)
|
|||
broker::integer g = *has_type;
|
||||
BroType t( static_cast<TypeTag>(g) );
|
||||
|
||||
Val* val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||
if ( ! val )
|
||||
{
|
||||
Unref(rf);
|
||||
return std::make_pair(false, nullptr);
|
||||
}
|
||||
|
||||
rf->frame[i] = val;
|
||||
rf->frame[i] = val.release();
|
||||
}
|
||||
|
||||
return std::make_pair(true, rf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue