mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Integrate review feedback
This commit is contained in:
parent
0f41b063b2
commit
72e15fe4d4
6 changed files with 18 additions and 27 deletions
|
@ -410,7 +410,7 @@ std::pair<bool, Frame*> Frame::Unserialize(const broker::vector& data)
|
||||||
return std::make_pair(false, nullptr);
|
return std::make_pair(false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
rf->frame[i] = val.release();
|
rf->frame[i] = val.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(true, rf);
|
return std::make_pair(true, rf);
|
||||||
|
|
|
@ -5,15 +5,6 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// These forward declarations only exist to enable ADL for the Ref and Unref
|
|
||||||
// functions.
|
|
||||||
|
|
||||||
struct IntrusivePtrDummy;
|
|
||||||
|
|
||||||
void Ref(IntrusivePtrDummy*);
|
|
||||||
|
|
||||||
void Unref(IntrusivePtrDummy*);
|
|
||||||
|
|
||||||
// An intrusive, reference counting smart pointer implementation.
|
// An intrusive, reference counting smart pointer implementation.
|
||||||
template <class T>
|
template <class T>
|
||||||
class IntrusivePtr {
|
class IntrusivePtr {
|
||||||
|
@ -65,7 +56,7 @@ public:
|
||||||
|
|
||||||
~IntrusivePtr()
|
~IntrusivePtr()
|
||||||
{
|
{
|
||||||
if (ptr_)
|
if ( ptr_ )
|
||||||
Unref(ptr_);
|
Unref(ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +67,10 @@ public:
|
||||||
|
|
||||||
// Returns the raw pointer without modifying the reference count and sets
|
// Returns the raw pointer without modifying the reference count and sets
|
||||||
// this to `nullptr`.
|
// this to `nullptr`.
|
||||||
pointer release() noexcept
|
pointer detach() noexcept
|
||||||
{
|
{
|
||||||
auto result = ptr_;
|
auto result = ptr_;
|
||||||
if (result)
|
if ( result )
|
||||||
ptr_ = nullptr;
|
ptr_ = nullptr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +79,7 @@ public:
|
||||||
{
|
{
|
||||||
auto old = ptr_;
|
auto old = ptr_;
|
||||||
setPtr(new_value, add_ref);
|
setPtr(new_value, add_ref);
|
||||||
if (old)
|
if ( old )
|
||||||
Unref(old);
|
Unref(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3159,7 +3159,7 @@ Val* cast_value_to_type(Val* v, BroType* t)
|
||||||
if ( ! dv )
|
if ( ! dv )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return static_cast<bro_broker::DataVal *>(dv)->castTo(t).release();
|
return static_cast<bro_broker::DataVal *>(dv)->castTo(t).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -229,14 +229,14 @@ struct val_converter {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_val->Append(index_val.release());
|
list_val->Append(index_val.detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rval->Assign(list_val.get(), nullptr);
|
rval->Assign(list_val.get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
result_type operator()(broker::table& a)
|
result_type operator()(broker::table& a)
|
||||||
|
@ -293,7 +293,7 @@ struct val_converter {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_val->Append(index_val.release());
|
list_val->Append(index_val.detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto value_val = bro_broker::data_to_val(move(item.second),
|
auto value_val = bro_broker::data_to_val(move(item.second),
|
||||||
|
@ -304,10 +304,10 @@ struct val_converter {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval->Assign(list_val.get(), value_val.release());
|
rval->Assign(list_val.get(), value_val.detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
result_type operator()(broker::vector& a)
|
result_type operator()(broker::vector& a)
|
||||||
|
@ -326,10 +326,10 @@ struct val_converter {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval->Assign(rval->Size(), item_val.release());
|
rval->Assign(rval->Size(), item_val.detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.detach();
|
||||||
}
|
}
|
||||||
else if ( type->Tag() == TYPE_FUNC )
|
else if ( type->Tag() == TYPE_FUNC )
|
||||||
{
|
{
|
||||||
|
@ -399,11 +399,11 @@ struct val_converter {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval->Assign(i, item_val.release());
|
rval->Assign(i, item_val.detach());
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.detach();
|
||||||
}
|
}
|
||||||
else if ( type->Tag() == TYPE_PATTERN )
|
else if ( type->Tag() == TYPE_PATTERN )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
||||||
auto val = data_to_val(std::move(args[i]), expected_type);
|
auto val = data_to_val(std::move(args[i]), expected_type);
|
||||||
|
|
||||||
if ( val )
|
if ( val )
|
||||||
vl.push_back(val.release());
|
vl.push_back(val.detach());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto expected_name = type_name(expected_type->Tag());
|
auto expected_name = type_name(expected_type->Tag());
|
||||||
|
@ -1245,7 +1245,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
id->SetVal(val.release());
|
id->SetVal(val.detach());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,7 +512,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
|
||||||
|
|
||||||
Element* e = new Element();
|
Element* e = new Element();
|
||||||
e->epsilon = *epsilon;
|
e->epsilon = *epsilon;
|
||||||
e->value = val.release();
|
e->value = val.detach();
|
||||||
e->parent = b;
|
e->parent = b;
|
||||||
|
|
||||||
b->elements.insert(b->elements.end(), e);
|
b->elements.insert(b->elements.end(), e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue