mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
IntrusivePtr: rename detach() to release()
Follow the C++ standard library conventions (here: `std::unique_ptr`).
This commit is contained in:
parent
edb93d1733
commit
08128b244f
11 changed files with 29 additions and 29 deletions
|
@ -2873,7 +2873,7 @@ void IndexExpr::Assign(Frame* f, Val* arg_v)
|
||||||
for ( auto idx = 0u; idx < v_vect->Size(); idx++, first++ )
|
for ( auto idx = 0u; idx < v_vect->Size(); idx++, first++ )
|
||||||
v1_vect->Insert(first, v_vect->Lookup(idx)->Ref());
|
v1_vect->Insert(first, v_vect->Lookup(idx)->Ref());
|
||||||
}
|
}
|
||||||
else if ( ! v1_vect->Assign(v2, v.detach()) )
|
else if ( ! v1_vect->Assign(v2, v.release()) )
|
||||||
{
|
{
|
||||||
v = v_extra;
|
v = v_extra;
|
||||||
|
|
||||||
|
@ -2895,7 +2895,7 @@ void IndexExpr::Assign(Frame* f, Val* arg_v)
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case TYPE_TABLE:
|
||||||
if ( ! v1->AsTableVal()->Assign(v2, v.detach()) )
|
if ( ! v1->AsTableVal()->Assign(v2, v.release()) )
|
||||||
{
|
{
|
||||||
v = v_extra;
|
v = v_extra;
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,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.detach();
|
rf->frame[i] = val.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(true, rf);
|
return std::make_pair(true, rf);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
setPtr(raw_ptr, add_ref);
|
setPtr(raw_ptr, add_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr(IntrusivePtr&& other) noexcept : ptr_(other.detach())
|
IntrusivePtr(IntrusivePtr&& other) noexcept : ptr_(other.release())
|
||||||
{
|
{
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class U, class = std::enable_if_t<std::is_convertible_v<U*, T*>>>
|
template <class U, class = std::enable_if_t<std::is_convertible_v<U*, T*>>>
|
||||||
IntrusivePtr(IntrusivePtr<U> other) noexcept : ptr_(other.detach())
|
IntrusivePtr(IntrusivePtr<U> other) noexcept : ptr_(other.release())
|
||||||
{
|
{
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
* intrusive pointer to @c nullptr.
|
* intrusive pointer to @c nullptr.
|
||||||
* @returns the raw pointer without modifying the reference count.
|
* @returns the raw pointer without modifying the reference count.
|
||||||
*/
|
*/
|
||||||
pointer detach() noexcept
|
pointer release() noexcept
|
||||||
{
|
{
|
||||||
auto result = ptr_;
|
auto result = ptr_;
|
||||||
if ( result )
|
if ( result )
|
||||||
|
|
|
@ -226,7 +226,7 @@ static Val* print_log(val_list* vals)
|
||||||
}
|
}
|
||||||
|
|
||||||
record->Assign(0, new Val(current_time(), TYPE_TIME));
|
record->Assign(0, new Val(current_time(), TYPE_TIME));
|
||||||
record->Assign(1, vec.detach());
|
record->Assign(1, vec.release());
|
||||||
log_mgr->Write(plval.get(), record.get());
|
log_mgr->Write(plval.get(), record.get());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3273,7 +3273,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).detach();
|
return static_cast<bro_broker::DataVal *>(dv)->castTo(t).release();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -252,14 +252,14 @@ struct val_converter {
|
||||||
if ( ! index_val )
|
if ( ! index_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
list_val->Append(index_val.detach());
|
list_val->Append(index_val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rval->Assign(list_val.get(), nullptr);
|
rval->Assign(list_val.get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
result_type operator()(broker::table& a)
|
result_type operator()(broker::table& a)
|
||||||
|
@ -312,7 +312,7 @@ struct val_converter {
|
||||||
if ( ! index_val )
|
if ( ! index_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
list_val->Append(index_val.detach());
|
list_val->Append(index_val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto value_val = bro_broker::data_to_val(move(item.second),
|
auto value_val = bro_broker::data_to_val(move(item.second),
|
||||||
|
@ -321,10 +321,10 @@ struct val_converter {
|
||||||
if ( ! value_val )
|
if ( ! value_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
rval->Assign(list_val.get(), value_val.detach());
|
rval->Assign(list_val.get(), value_val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
result_type operator()(broker::vector& a)
|
result_type operator()(broker::vector& a)
|
||||||
|
@ -341,10 +341,10 @@ struct val_converter {
|
||||||
if ( ! item_val )
|
if ( ! item_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
rval->Assign(rval->Size(), item_val.detach());
|
rval->Assign(rval->Size(), item_val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
}
|
}
|
||||||
else if ( type->Tag() == TYPE_FUNC )
|
else if ( type->Tag() == TYPE_FUNC )
|
||||||
{
|
{
|
||||||
|
@ -410,11 +410,11 @@ struct val_converter {
|
||||||
if ( ! item_val )
|
if ( ! item_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
rval->Assign(i, item_val.detach());
|
rval->Assign(i, item_val.release());
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
}
|
}
|
||||||
else if ( type->Tag() == TYPE_PATTERN )
|
else if ( type->Tag() == TYPE_PATTERN )
|
||||||
{
|
{
|
||||||
|
|
|
@ -998,7 +998,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.detach());
|
vl.push_back(val.release());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto expected_name = type_name(expected_type->Tag());
|
auto expected_name = type_name(expected_type->Tag());
|
||||||
|
@ -1210,7 +1210,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
id->SetVal(val.detach());
|
id->SetVal(val.release());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -514,7 +514,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.detach();
|
e->value = val.release();
|
||||||
e->parent = b;
|
e->parent = b;
|
||||||
|
|
||||||
b->elements.insert(b->elements.end(), e);
|
b->elements.insert(b->elements.end(), e);
|
||||||
|
|
|
@ -1152,7 +1152,7 @@ IntrusivePtr<RecordVal> Supervisor::NodeConfig::ToRecord() const
|
||||||
if ( ep.interface )
|
if ( ep.interface )
|
||||||
val->Assign(ept->FieldOffset("interface"), new StringVal(*ep.interface));
|
val->Assign(ept->FieldOffset("interface"), new StringVal(*ep.interface));
|
||||||
|
|
||||||
cluster_val->Assign(key.get(), val.detach());
|
cluster_val->Assign(key.get(), val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
@ -1163,7 +1163,7 @@ IntrusivePtr<RecordVal> Supervisor::Node::ToRecord() const
|
||||||
auto rt = BifType::Record::Supervisor::NodeStatus;
|
auto rt = BifType::Record::Supervisor::NodeStatus;
|
||||||
auto rval = make_intrusive<RecordVal>(rt);
|
auto rval = make_intrusive<RecordVal>(rt);
|
||||||
|
|
||||||
rval->Assign(rt->FieldOffset("node"), config.ToRecord().detach());
|
rval->Assign(rt->FieldOffset("node"), config.ToRecord().release());
|
||||||
|
|
||||||
if ( pid )
|
if ( pid )
|
||||||
rval->Assign(rt->FieldOffset("pid"), val_mgr->GetInt(pid));
|
rval->Assign(rt->FieldOffset("pid"), val_mgr->GetInt(pid));
|
||||||
|
@ -1230,7 +1230,7 @@ bool Supervisor::SupervisedNode::InitCluster() const
|
||||||
val->Assign(cluster_node_type->FieldOffset("manager"),
|
val->Assign(cluster_node_type->FieldOffset("manager"),
|
||||||
new StringVal(*manager_name));
|
new StringVal(*manager_name));
|
||||||
|
|
||||||
cluster_nodes->Assign(key.get(), val.detach());
|
cluster_nodes->Assign(key.get(), val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster_manager_is_logger_id->SetVal(val_mgr->GetBool(! has_logger));
|
cluster_manager_is_logger_id->SetVal(val_mgr->GetBool(! has_logger));
|
||||||
|
@ -1329,7 +1329,7 @@ RecordVal* Supervisor::Status(std::string_view node_name)
|
||||||
const auto& node = n.second;
|
const auto& node = n.second;
|
||||||
auto key = make_intrusive<StringVal>(name);
|
auto key = make_intrusive<StringVal>(name);
|
||||||
auto val = node.ToRecord();
|
auto val = node.ToRecord();
|
||||||
node_table_val->Assign(key.get(), val.detach());
|
node_table_val->Assign(key.get(), val.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1343,7 +1343,7 @@ RecordVal* Supervisor::Status(std::string_view node_name)
|
||||||
const auto& node = it->second;
|
const auto& node = it->second;
|
||||||
auto key = make_intrusive<StringVal>(name);
|
auto key = make_intrusive<StringVal>(name);
|
||||||
auto val = node.ToRecord();
|
auto val = node.ToRecord();
|
||||||
node_table_val->Assign(key.get(), val.detach());
|
node_table_val->Assign(key.get(), val.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -87,11 +87,11 @@ function Supervisor::__node%(%): Supervisor::NodeConfig
|
||||||
auto rt = BifType::Record::Supervisor::NodeConfig;
|
auto rt = BifType::Record::Supervisor::NodeConfig;
|
||||||
auto rval = make_intrusive<RecordVal>(rt);
|
auto rval = make_intrusive<RecordVal>(rt);
|
||||||
rval->Assign(rt->FieldOffset("name"), new StringVal("<invalid>"));
|
rval->Assign(rt->FieldOffset("name"), new StringVal("<invalid>"));
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rval = zeek::Supervisor::ThisNode()->config.ToRecord();
|
auto rval = zeek::Supervisor::ThisNode()->config.ToRecord();
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Supervisor::__is_supervisor%(%): bool
|
function Supervisor::__is_supervisor%(%): bool
|
||||||
|
|
|
@ -1868,7 +1868,7 @@ function zeek_args%(%): string_vec
|
||||||
for ( auto i = 0; i < bro_argc; ++i )
|
for ( auto i = 0; i < bro_argc; ++i )
|
||||||
rval->Assign(rval->Size(), new StringVal(bro_argv[i]));
|
rval->Assign(rval->Size(), new StringVal(bro_argv[i]));
|
||||||
|
|
||||||
return rval.detach();
|
return rval.release();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Checks whether Zeek reads traffic from one or more network interfaces (as
|
## Checks whether Zeek reads traffic from one or more network interfaces (as
|
||||||
|
@ -1912,7 +1912,7 @@ function packet_source%(%): PacketSource
|
||||||
r->Assign(3, val_mgr->GetCount(ps->Netmask()));
|
r->Assign(3, val_mgr->GetCount(ps->Netmask()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.detach();
|
return r.release();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Generates a table of the size of all global variables. The table index is
|
## Generates a table of the size of all global variables. The table index is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue