mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Deprecate TableVal::Assign methods with Val*, add IntrusivePtr overloads
This commit is contained in:
parent
5bf2ed02d7
commit
7e89c8f0df
22 changed files with 106 additions and 95 deletions
3
NEWS
3
NEWS
|
@ -205,6 +205,9 @@ Deprecated Functionality
|
||||||
- ``RecordVal::Lookup(const char*, bool)`` is deprecated, use either
|
- ``RecordVal::Lookup(const char*, bool)`` is deprecated, use either
|
||||||
``RecordVal::GetField()`` or ``RecordVal::GetFieldOrDefault()``.
|
``RecordVal::GetField()`` or ``RecordVal::GetFieldOrDefault()``.
|
||||||
|
|
||||||
|
- ``TableVal::Assign`` methods taking raw ``Val*`` are deprecated, use the
|
||||||
|
overloads taking ``IntrusivePtr``.
|
||||||
|
|
||||||
Zeek 3.1.0
|
Zeek 3.1.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -952,13 +952,13 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
|
||||||
kp1 = RecoverOneVal(k, kp1, k_end, tt->Indices(), &key, false);
|
kp1 = RecoverOneVal(k, kp1, k_end, tt->Indices(), &key, false);
|
||||||
|
|
||||||
if ( t->IsSet() )
|
if ( t->IsSet() )
|
||||||
tv->Assign(key.get(), nullptr);
|
tv->Assign(std::move(key), nullptr);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IntrusivePtr<Val> value;
|
IntrusivePtr<Val> value;
|
||||||
kp1 = RecoverOneVal(k, kp1, k_end, tt->Yield().get(), &value,
|
kp1 = RecoverOneVal(k, kp1, k_end, tt->Yield().get(), &value,
|
||||||
false);
|
false);
|
||||||
tv->Assign(key.get(), std::move(value));
|
tv->Assign(std::move(key), std::move(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/Expr.cc
10
src/Expr.cc
|
@ -2321,7 +2321,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
|
||||||
if ( ! index || ! v )
|
if ( ! index || ! v )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! tv->Assign(index.get(), std::move(v)) )
|
if ( ! tv->Assign(std::move(index), std::move(v)) )
|
||||||
RuntimeError("type clash in table assignment");
|
RuntimeError("type clash in table assignment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2532,7 +2532,7 @@ void IndexExpr::Add(Frame* f)
|
||||||
if ( ! v2 )
|
if ( ! v2 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
v1->AsTableVal()->Assign(v2.get(), nullptr);
|
v1->AsTableVal()->Assign(std::move(v2), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexExpr::Delete(Frame* f)
|
void IndexExpr::Delete(Frame* f)
|
||||||
|
@ -2780,7 +2780,7 @@ void IndexExpr::Assign(Frame* f, IntrusivePtr<Val> v)
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case TYPE_TABLE:
|
||||||
if ( ! v1->AsTableVal()->Assign(v2.get(), std::move(v)) )
|
if ( ! v1->AsTableVal()->Assign(std::move(v2), std::move(v)) )
|
||||||
{
|
{
|
||||||
v = std::move(v_extra);
|
v = std::move(v_extra);
|
||||||
|
|
||||||
|
@ -3256,7 +3256,7 @@ IntrusivePtr<Val> SetConstructorExpr::Eval(Frame* f) const
|
||||||
for ( const auto& expr : exprs )
|
for ( const auto& expr : exprs )
|
||||||
{
|
{
|
||||||
auto element = expr->Eval(f);
|
auto element = expr->Eval(f);
|
||||||
aggr->Assign(element.get(), nullptr);
|
aggr->Assign(std::move(element), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return aggr;
|
return aggr;
|
||||||
|
@ -3278,7 +3278,7 @@ IntrusivePtr<Val> SetConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val
|
||||||
{
|
{
|
||||||
auto element = check_and_promote(e->Eval(nullptr), index_type, true);
|
auto element = check_and_promote(e->Eval(nullptr), index_type, true);
|
||||||
|
|
||||||
if ( ! element || ! tval->Assign(element.get(), nullptr) )
|
if ( ! element || ! tval->Assign(std::move(element), nullptr) )
|
||||||
{
|
{
|
||||||
Error(fmt("initialization type mismatch in set"), e);
|
Error(fmt("initialization type mismatch in set"), e);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
10
src/Stats.cc
10
src/Stats.cc
|
@ -353,16 +353,14 @@ SampleLogger::~SampleLogger()
|
||||||
|
|
||||||
void SampleLogger::FunctionSeen(const Func* func)
|
void SampleLogger::FunctionSeen(const Func* func)
|
||||||
{
|
{
|
||||||
Val* idx = new StringVal(func->Name());
|
auto idx = make_intrusive<StringVal>(func->Name());
|
||||||
load_samples->Assign(idx, nullptr);
|
load_samples->Assign(std::move(idx), nullptr);
|
||||||
Unref(idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleLogger::LocationSeen(const Location* loc)
|
void SampleLogger::LocationSeen(const Location* loc)
|
||||||
{
|
{
|
||||||
Val* idx = new StringVal(loc->filename);
|
auto idx = make_intrusive<StringVal>(loc->filename);
|
||||||
load_samples->Assign(idx, nullptr);
|
load_samples->Assign(std::move(idx), nullptr);
|
||||||
Unref(idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleLogger::SegmentProfile(const char* /* name */,
|
void SampleLogger::SegmentProfile(const char* /* name */,
|
||||||
|
|
|
@ -818,9 +818,8 @@ IntrusivePtr<TableVal> RecordType::GetRecordFieldsVal(const RecordVal* rv) const
|
||||||
nr->Assign(1, val_mgr->Bool(logged));
|
nr->Assign(1, val_mgr->Bool(logged));
|
||||||
nr->Assign(2, std::move(fv));
|
nr->Assign(2, std::move(fv));
|
||||||
nr->Assign(3, FieldDefault(i));
|
nr->Assign(3, FieldDefault(i));
|
||||||
Val* field_name = new StringVal(FieldName(i));
|
auto field_name = make_intrusive<StringVal>(FieldName(i));
|
||||||
rval->Assign(field_name, std::move(nr));
|
rval->Assign(std::move(field_name), std::move(nr));
|
||||||
Unref(field_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
43
src/Val.cc
43
src/Val.cc
|
@ -1244,7 +1244,7 @@ IntrusivePtr<TableVal> ListVal::ToSetVal() const
|
||||||
auto t = make_intrusive<TableVal>(std::move(s));
|
auto t = make_intrusive<TableVal>(std::move(s));
|
||||||
|
|
||||||
for ( const auto& val : vals )
|
for ( const auto& val : vals )
|
||||||
t->Assign(val.get(), nullptr);
|
t->Assign(val, nullptr);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -1506,24 +1506,24 @@ void TableVal::CheckExpireAttr(attr_tag at)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TableVal::Assign(Val* index, IntrusivePtr<Val> new_val)
|
bool TableVal::Assign(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
|
||||||
{
|
{
|
||||||
HashKey* k = ComputeHash(index);
|
HashKey* k = ComputeHash(index.get());
|
||||||
if ( ! k )
|
if ( ! k )
|
||||||
{
|
{
|
||||||
index->Error("index type doesn't match table", table_type->Indices());
|
index->Error("index type doesn't match table", table_type->Indices());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Assign(index, k, std::move(new_val));
|
return Assign(std::move(index), k, std::move(new_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TableVal::Assign(Val* index, Val* new_val)
|
bool TableVal::Assign(Val* index, Val* new_val)
|
||||||
{
|
{
|
||||||
return Assign(index, {AdoptRef{}, new_val});
|
return Assign({NewRef{}, index}, {AdoptRef{}, new_val});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TableVal::Assign(Val* index, HashKey* k, IntrusivePtr<Val> new_val)
|
bool TableVal::Assign(IntrusivePtr<Val> index, HashKey* k, IntrusivePtr<Val> new_val)
|
||||||
{
|
{
|
||||||
bool is_set = table_type->IsSet();
|
bool is_set = table_type->IsSet();
|
||||||
|
|
||||||
|
@ -1548,7 +1548,7 @@ bool TableVal::Assign(Val* index, HashKey* k, IntrusivePtr<Val> new_val)
|
||||||
subnets->Insert(v.get(), new_entry_val);
|
subnets->Insert(v.get(), new_entry_val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
subnets->Insert(index, new_entry_val);
|
subnets->Insert(index.get(), new_entry_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep old expiration time if necessary.
|
// Keep old expiration time if necessary.
|
||||||
|
@ -1559,8 +1559,7 @@ bool TableVal::Assign(Val* index, HashKey* k, IntrusivePtr<Val> new_val)
|
||||||
|
|
||||||
if ( change_func )
|
if ( change_func )
|
||||||
{
|
{
|
||||||
auto change_index = index ? IntrusivePtr<Val>{NewRef{}, index}
|
auto change_index = index ? std::move(index) : RecoverIndex(&k_copy);
|
||||||
: RecoverIndex(&k_copy);
|
|
||||||
auto v = old_entry_val ? old_entry_val->GetVal() : new_val;
|
auto v = old_entry_val ? old_entry_val->GetVal() : new_val;
|
||||||
CallChangeFunc(change_index.get(), v.get(), old_entry_val ? ELEMENT_CHANGED : ELEMENT_NEW);
|
CallChangeFunc(change_index.get(), v.get(), old_entry_val ? ELEMENT_CHANGED : ELEMENT_NEW);
|
||||||
}
|
}
|
||||||
|
@ -1572,7 +1571,7 @@ bool TableVal::Assign(Val* index, HashKey* k, IntrusivePtr<Val> new_val)
|
||||||
|
|
||||||
bool TableVal::Assign(Val* index, HashKey* k, Val* new_val)
|
bool TableVal::Assign(Val* index, HashKey* k, Val* new_val)
|
||||||
{
|
{
|
||||||
return Assign(index, k, {AdoptRef{}, new_val});
|
return Assign({NewRef{}, index}, k, {AdoptRef{}, new_val});
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Val> TableVal::SizeVal() const
|
IntrusivePtr<Val> TableVal::SizeVal() const
|
||||||
|
@ -1618,7 +1617,7 @@ bool TableVal::AddTo(Val* val, bool is_first_init, bool propagate_ops) const
|
||||||
|
|
||||||
if ( type->IsSet() )
|
if ( type->IsSet() )
|
||||||
{
|
{
|
||||||
if ( ! t->Assign(v->GetVal().get(), k, nullptr) )
|
if ( ! t->Assign(v->GetVal(), k, nullptr) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1762,7 +1761,7 @@ bool TableVal::ExpandAndInit(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
|
||||||
|
|
||||||
if ( index_type->Tag() != TYPE_LIST )
|
if ( index_type->Tag() != TYPE_LIST )
|
||||||
// Nothing to expand.
|
// Nothing to expand.
|
||||||
return CheckAndAssign(index.get(), std::move(new_val));
|
return CheckAndAssign(std::move(index), std::move(new_val));
|
||||||
|
|
||||||
ListVal* iv = index->AsListVal();
|
ListVal* iv = index->AsListVal();
|
||||||
if ( iv->BaseTag() != TYPE_ANY )
|
if ( iv->BaseTag() != TYPE_ANY )
|
||||||
|
@ -1795,7 +1794,7 @@ bool TableVal::ExpandAndInit(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
|
||||||
|
|
||||||
if ( i >= iv->Length() )
|
if ( i >= iv->Length() )
|
||||||
// Nothing to expand.
|
// Nothing to expand.
|
||||||
return CheckAndAssign(index.get(), std::move(new_val));
|
return CheckAndAssign(std::move(index), std::move(new_val));
|
||||||
else
|
else
|
||||||
return ExpandCompoundAndInit(iv, i, std::move(new_val));
|
return ExpandCompoundAndInit(iv, i, std::move(new_val));
|
||||||
}
|
}
|
||||||
|
@ -1960,21 +1959,19 @@ IntrusivePtr<TableVal> TableVal::LookupSubnetValues(const SubNetVal* search)
|
||||||
auto matches = subnets->FindAll(search);
|
auto matches = subnets->FindAll(search);
|
||||||
for ( auto element : matches )
|
for ( auto element : matches )
|
||||||
{
|
{
|
||||||
SubNetVal* s = new SubNetVal(get<0>(element));
|
auto s = make_intrusive<SubNetVal>(get<0>(element));
|
||||||
TableEntryVal* entry = reinterpret_cast<TableEntryVal*>(get<1>(element));
|
TableEntryVal* entry = reinterpret_cast<TableEntryVal*>(get<1>(element));
|
||||||
|
|
||||||
if ( entry && entry->GetVal() )
|
if ( entry && entry->GetVal() )
|
||||||
nt->Assign(s, entry->GetVal());
|
nt->Assign(std::move(s), entry->GetVal());
|
||||||
else
|
else
|
||||||
nt->Assign(s, nullptr); // set
|
nt->Assign(std::move(s), nullptr); // set
|
||||||
|
|
||||||
if ( entry )
|
if ( entry )
|
||||||
{
|
{
|
||||||
if ( attrs && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
if ( attrs && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
||||||
entry->SetExpireAccess(network_time);
|
entry->SetExpireAccess(network_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
Unref(s); // assign does not consume index
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nt;
|
return nt;
|
||||||
|
@ -2294,19 +2291,19 @@ bool TableVal::ExpandCompoundAndInit(ListVal* lv, int k, IntrusivePtr<Val> new_v
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TableVal::CheckAndAssign(Val* index, IntrusivePtr<Val> new_val)
|
bool TableVal::CheckAndAssign(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
|
||||||
{
|
{
|
||||||
Val* v = nullptr;
|
Val* v = nullptr;
|
||||||
if ( subnets )
|
if ( subnets )
|
||||||
// We need an exact match here.
|
// We need an exact match here.
|
||||||
v = (Val*) subnets->Lookup(index, true);
|
v = (Val*) subnets->Lookup(index.get(), true);
|
||||||
else
|
else
|
||||||
v = Lookup(index, false).get();
|
v = Lookup(index.get(), false).get();
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
index->Warn("multiple initializations for index");
|
index->Warn("multiple initializations for index");
|
||||||
|
|
||||||
return Assign(index, std::move(new_val));
|
return Assign(std::move(index), std::move(new_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableVal::InitDefaultFunc(Frame* f)
|
void TableVal::InitDefaultFunc(Frame* f)
|
||||||
|
@ -2655,7 +2652,7 @@ void TableVal::RebuildTable(ParseTimeTableState ptts)
|
||||||
table_type->Indices()));
|
table_type->Indices()));
|
||||||
|
|
||||||
for ( auto& [key, val] : ptts )
|
for ( auto& [key, val] : ptts )
|
||||||
Assign(key.get(), val.release());
|
Assign(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
TableVal::ParseTimeTableStates TableVal::parse_time_table_states;
|
TableVal::ParseTimeTableStates TableVal::parse_time_table_states;
|
||||||
|
|
38
src/Val.h
38
src/Val.h
|
@ -741,14 +741,38 @@ public:
|
||||||
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> attrs = nullptr);
|
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> attrs = nullptr);
|
||||||
~TableVal() override;
|
~TableVal() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns a value at an associated index in the table (or in the
|
||||||
|
* case of a set, just adds the index).
|
||||||
|
* @param index The key to assign.
|
||||||
|
* @param new_val The value to assign at the index. For a set, this
|
||||||
|
* must be nullptr.
|
||||||
|
* @return True if the assignment type-checked.
|
||||||
|
*/
|
||||||
|
bool Assign(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns a value at an associated index in the table (or in the
|
||||||
|
* case of a set, just adds the index).
|
||||||
|
* @param index The key to assign. For tables, this is allowed to be null
|
||||||
|
* (if needed, the index val can be recovered from the hash key).
|
||||||
|
* @param k A precomputed hash key to use (this method takes ownership
|
||||||
|
* of deleting it).
|
||||||
|
* @param new_val The value to assign at the index. For a set, this
|
||||||
|
* must be nullptr.
|
||||||
|
* @return True if the assignment type-checked.
|
||||||
|
*/
|
||||||
|
bool Assign(IntrusivePtr<Val> index, HashKey* k, IntrusivePtr<Val> new_val);
|
||||||
|
|
||||||
// Returns true if the assignment typechecked, false if not. The
|
// Returns true if the assignment typechecked, false if not. The
|
||||||
// methods take ownership of new_val, but not of the index. Second
|
// methods take ownership of new_val, but not of the index. If we're
|
||||||
// version takes a HashKey and Unref()'s it when done. If we're a
|
// a set, new_val has to be nil.
|
||||||
// set, new_val has to be nil. If we aren't a set, index may be nil
|
[[deprecated("Remove in v4.1. Use IntrusivePtr overload instead.")]]
|
||||||
// in the second version.
|
|
||||||
bool Assign(Val* index, IntrusivePtr<Val> new_val);
|
|
||||||
bool Assign(Val* index, Val* new_val);
|
bool Assign(Val* index, Val* new_val);
|
||||||
bool Assign(Val* index, HashKey* k, IntrusivePtr<Val> new_val);
|
|
||||||
|
// Same as other Assign() method, but takes a precomuted HashKey and
|
||||||
|
// deletes it when done.
|
||||||
|
[[deprecated("Remove in v4.1. Use IntrusivePtr overload instead.")]]
|
||||||
bool Assign(Val* index, HashKey* k, Val* new_val);
|
bool Assign(Val* index, HashKey* k, Val* new_val);
|
||||||
|
|
||||||
IntrusivePtr<Val> SizeVal() const override;
|
IntrusivePtr<Val> SizeVal() const override;
|
||||||
|
@ -890,7 +914,7 @@ protected:
|
||||||
|
|
||||||
void CheckExpireAttr(attr_tag at);
|
void CheckExpireAttr(attr_tag at);
|
||||||
bool ExpandCompoundAndInit(ListVal* lv, int k, IntrusivePtr<Val> new_val);
|
bool ExpandCompoundAndInit(ListVal* lv, int k, IntrusivePtr<Val> new_val);
|
||||||
bool CheckAndAssign(Val* index, IntrusivePtr<Val> new_val);
|
bool CheckAndAssign(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val);
|
||||||
|
|
||||||
// Calculates default value for index. Returns 0 if none.
|
// Calculates default value for index. Returns 0 if none.
|
||||||
IntrusivePtr<Val> Default(Val* index);
|
IntrusivePtr<Val> Default(Val* index);
|
||||||
|
|
|
@ -477,35 +477,29 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name,
|
||||||
uint32_t ad = extract_uint32((u_char*) value);
|
uint32_t ad = extract_uint32((u_char*) value);
|
||||||
uint16_t pt = ntohs((value[4] << 8) | value[5]);
|
uint16_t pt = ntohs((value[4] << 8) | value[5]);
|
||||||
|
|
||||||
RecordVal* peer = new RecordVal(bittorrent_peer);
|
auto peer = make_intrusive<RecordVal>(bittorrent_peer);
|
||||||
peer->Assign(0, make_intrusive<AddrVal>(ad));
|
peer->Assign(0, make_intrusive<AddrVal>(ad));
|
||||||
peer->Assign(1, val_mgr->Port(pt, TRANSPORT_TCP));
|
peer->Assign(1, val_mgr->Port(pt, TRANSPORT_TCP));
|
||||||
res_val_peers->Assign(peer, nullptr);
|
res_val_peers->Assign(std::move(peer), nullptr);
|
||||||
|
|
||||||
Unref(peer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringVal* name_ = new StringVal(name_len, name);
|
auto name_ = make_intrusive<StringVal>(name_len, name);
|
||||||
auto benc_value = make_intrusive<RecordVal>(bittorrent_benc_value);
|
auto benc_value = make_intrusive<RecordVal>(bittorrent_benc_value);
|
||||||
benc_value->Assign(type, make_intrusive<StringVal>(value_len, value));
|
benc_value->Assign(type, make_intrusive<StringVal>(value_len, value));
|
||||||
res_val_benc->Assign(name_, std::move(benc_value));
|
res_val_benc->Assign(std::move(name_), std::move(benc_value));
|
||||||
|
|
||||||
Unref(name_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name,
|
void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name,
|
||||||
enum btt_benc_types type, bro_int_t value)
|
enum btt_benc_types type, bro_int_t value)
|
||||||
{
|
{
|
||||||
RecordVal* benc_value = new RecordVal(bittorrent_benc_value);
|
auto benc_value = make_intrusive<RecordVal>(bittorrent_benc_value);
|
||||||
StringVal* name_ = new StringVal(name_len, name);
|
auto name_ = make_intrusive<StringVal>(name_len, name);
|
||||||
|
|
||||||
benc_value->Assign(type, val_mgr->Int(value));
|
benc_value->Assign(type, val_mgr->Int(value));
|
||||||
res_val_benc->Assign(name_, benc_value);
|
res_val_benc->Assign(std::move(name_), std::move(benc_value));
|
||||||
|
|
||||||
Unref(name_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitTorrentTracker_Analyzer::ResponseBody(void)
|
void BitTorrentTracker_Analyzer::ResponseBody(void)
|
||||||
|
|
|
@ -280,7 +280,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
if ( parts[i][0] == '@' )
|
if ( parts[i][0] == '@' )
|
||||||
parts[i] = parts[i].substr(1);
|
parts[i] = parts[i].substr(1);
|
||||||
auto idx = make_intrusive<StringVal>(parts[i].c_str());
|
auto idx = make_intrusive<StringVal>(parts[i].c_str());
|
||||||
set->Assign(idx.get(), nullptr);
|
set->Assign(std::move(idx), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueueConnEvent(irc_names_info,
|
EnqueueConnEvent(irc_names_info,
|
||||||
|
@ -471,7 +471,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
for ( unsigned int i = 0; i < parts.size(); ++i )
|
for ( unsigned int i = 0; i < parts.size(); ++i )
|
||||||
{
|
{
|
||||||
auto idx = make_intrusive<StringVal>(parts[i].c_str());
|
auto idx = make_intrusive<StringVal>(parts[i].c_str());
|
||||||
set->Assign(idx.get(), nullptr);
|
set->Assign(std::move(idx), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueueConnEvent(irc_whois_channel_line,
|
EnqueueConnEvent(irc_whois_channel_line,
|
||||||
|
@ -849,7 +849,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
string empty_string = "";
|
string empty_string = "";
|
||||||
for ( unsigned int i = 0; i < channels.size(); ++i )
|
for ( unsigned int i = 0; i < channels.size(); ++i )
|
||||||
{
|
{
|
||||||
RecordVal* info = new RecordVal(irc_join_info);
|
auto info = make_intrusive<RecordVal>(irc_join_info);
|
||||||
info->Assign(0, make_intrusive<StringVal>(nickname.c_str()));
|
info->Assign(0, make_intrusive<StringVal>(nickname.c_str()));
|
||||||
info->Assign(1, make_intrusive<StringVal>(channels[i].c_str()));
|
info->Assign(1, make_intrusive<StringVal>(channels[i].c_str()));
|
||||||
if ( i < passwords.size() )
|
if ( i < passwords.size() )
|
||||||
|
@ -858,8 +858,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
info->Assign(2, make_intrusive<StringVal>(empty_string.c_str()));
|
info->Assign(2, make_intrusive<StringVal>(empty_string.c_str()));
|
||||||
// User mode.
|
// User mode.
|
||||||
info->Assign(3, make_intrusive<StringVal>(empty_string.c_str()));
|
info->Assign(3, make_intrusive<StringVal>(empty_string.c_str()));
|
||||||
list->Assign(info, nullptr);
|
list->Assign(std::move(info), nullptr);
|
||||||
Unref(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueueConnEvent(irc_join_message,
|
EnqueueConnEvent(irc_join_message,
|
||||||
|
@ -919,7 +918,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
info->Assign(2, make_intrusive<StringVal>(empty_string.c_str()));
|
info->Assign(2, make_intrusive<StringVal>(empty_string.c_str()));
|
||||||
// User mode:
|
// User mode:
|
||||||
info->Assign(3, make_intrusive<StringVal>(mode.c_str()));
|
info->Assign(3, make_intrusive<StringVal>(mode.c_str()));
|
||||||
list->Assign(info.get(), nullptr);
|
list->Assign(std::move(info), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueueConnEvent(irc_join_message,
|
EnqueueConnEvent(irc_join_message,
|
||||||
|
@ -958,7 +957,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
for ( unsigned int i = 0; i < channelList.size(); ++i )
|
for ( unsigned int i = 0; i < channelList.size(); ++i )
|
||||||
{
|
{
|
||||||
auto idx = make_intrusive<StringVal>(channelList[i].c_str());
|
auto idx = make_intrusive<StringVal>(channelList[i].c_str());
|
||||||
set->Assign(idx.get(), nullptr);
|
set->Assign(std::move(idx), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueueConnEvent(irc_part_message,
|
EnqueueConnEvent(irc_part_message,
|
||||||
|
|
|
@ -1308,7 +1308,7 @@ IntrusivePtr<TableVal> MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
|
||||||
{
|
{
|
||||||
auto index = val_mgr->Count(i + 1); // index starting from 1
|
auto index = val_mgr->Count(i + 1); // index starting from 1
|
||||||
MIME_Header* h = hlist[i];
|
MIME_Header* h = hlist[i];
|
||||||
t->Assign(index.get(), BuildHeaderVal(h));
|
t->Assign(std::move(index), BuildHeaderVal(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -34,7 +34,7 @@ refine flow RADIUS_Flow += {
|
||||||
{
|
{
|
||||||
auto attribute_list = make_intrusive<VectorVal>(zeek::BifType::Vector::RADIUS::AttributeList);
|
auto attribute_list = make_intrusive<VectorVal>(zeek::BifType::Vector::RADIUS::AttributeList);
|
||||||
attribute_list->Assign((unsigned int)0, std::move(val));
|
attribute_list->Assign((unsigned int)0, std::move(val));
|
||||||
attributes->Assign(index.get(), std::move(attribute_list));
|
attributes->Assign(std::move(index), std::move(attribute_list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auto index = val_mgr->Count(++nmap);
|
auto index = val_mgr->Count(++nmap);
|
||||||
mappings->Assign(index.get(), std::move(m));
|
mappings->Assign(std::move(index), std::move(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! buf )
|
if ( ! buf )
|
||||||
|
|
|
@ -3,7 +3,7 @@ refine flow SIP_Flow += {
|
||||||
%member{
|
%member{
|
||||||
int content_length;
|
int content_length;
|
||||||
bool build_headers;
|
bool build_headers;
|
||||||
vector<BroVal> headers;
|
std::vector<IntrusivePtr<Val>> headers;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%init{
|
%init{
|
||||||
|
@ -59,7 +59,7 @@ refine flow SIP_Flow += {
|
||||||
|
|
||||||
if ( build_headers )
|
if ( build_headers )
|
||||||
{
|
{
|
||||||
headers.push_back(build_sip_header_val(name, value));
|
headers.push_back({AdoptRef{}, build_sip_header_val(name, value)});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +73,7 @@ refine flow SIP_Flow += {
|
||||||
for ( unsigned int i = 0; i < headers.size(); ++i )
|
for ( unsigned int i = 0; i < headers.size(); ++i )
|
||||||
{ // index starting from 1
|
{ // index starting from 1
|
||||||
auto index = val_mgr->Count(i + 1);
|
auto index = val_mgr->Count(i + 1);
|
||||||
t->Assign(index.get(), headers[i]);
|
t->Assign(std::move(index), std::move(headers[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -256,7 +256,7 @@ struct val_converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rval->Assign(list_val.get(), nullptr);
|
rval->Assign(std::move(list_val), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.release();
|
||||||
|
@ -320,7 +320,7 @@ struct val_converter {
|
||||||
if ( ! value_val )
|
if ( ! value_val )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
rval->Assign(list_val.get(), std::move(value_val));
|
rval->Assign(std::move(list_val), std::move(value_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval.release();
|
return rval.release();
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
|
||||||
if ( conns->AsTableVal()->Lookup(idx.get()) )
|
if ( conns->AsTableVal()->Lookup(idx.get()) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
conns->AsTableVal()->Assign(idx.get(), conn->ConnVal());
|
conns->AsTableVal()->Assign(std::move(idx), conn->ConnVal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ IntrusivePtr<TableVal> characteristics_to_bro(uint32_t c, uint8_t len)
|
||||||
if ( ((c >> i) & 0x1) == 1 )
|
if ( ((c >> i) & 0x1) == 1 )
|
||||||
{
|
{
|
||||||
auto ch = val_mgr->Count((1<<i)&mask);
|
auto ch = val_mgr->Count((1<<i)&mask);
|
||||||
char_set->Assign(ch.get(), 0);
|
char_set->Assign(std::move(ch), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1256,8 +1256,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
|
||||||
ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash());
|
ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash());
|
||||||
ih->valhash = valhash;
|
ih->valhash = valhash;
|
||||||
|
|
||||||
stream->tab->Assign(idxval, k, valval);
|
stream->tab->Assign({AdoptRef{}, idxval}, k, {AdoptRef{}, valval});
|
||||||
Unref(idxval); // asssign does not consume idxval.
|
|
||||||
|
|
||||||
if ( predidx != nullptr )
|
if ( predidx != nullptr )
|
||||||
Unref(predidx);
|
Unref(predidx);
|
||||||
|
@ -1603,7 +1602,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->tab->Assign(idxval, valval);
|
stream->tab->Assign({NewRef{}, idxval}, {AdoptRef{}, valval});
|
||||||
|
|
||||||
if ( stream->event )
|
if ( stream->event )
|
||||||
{
|
{
|
||||||
|
@ -1641,7 +1640,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
|
||||||
}
|
}
|
||||||
|
|
||||||
else // no predicates or other stuff
|
else // no predicates or other stuff
|
||||||
stream->tab->Assign(idxval, valval);
|
stream->tab->Assign({NewRef{}, idxval}, {AdoptRef{}, valval});
|
||||||
|
|
||||||
Unref(idxval); // not consumed by assign
|
Unref(idxval); // not consumed by assign
|
||||||
|
|
||||||
|
@ -2331,8 +2330,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
||||||
{
|
{
|
||||||
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type.get(), have_error);
|
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type.get(), have_error);
|
||||||
|
|
||||||
t->Assign(assignval, nullptr);
|
t->Assign({AdoptRef{}, assignval}, nullptr);
|
||||||
Unref(assignval); // index is not consumed by assign.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
@ -2512,8 +2510,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
|
||||||
{
|
{
|
||||||
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], have_error);
|
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], have_error);
|
||||||
|
|
||||||
t->Assign(assignval, nullptr);
|
t->Assign({AdoptRef{}, assignval}, nullptr);
|
||||||
Unref(assignval); // index is not consumed by assign.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -157,7 +157,7 @@ function Reporter::get_weird_sampling_whitelist%(%): string_set
|
||||||
for ( auto el : reporter->GetWeirdSamplingWhitelist() )
|
for ( auto el : reporter->GetWeirdSamplingWhitelist() )
|
||||||
{
|
{
|
||||||
auto idx = make_intrusive<StringVal>(el);
|
auto idx = make_intrusive<StringVal>(el);
|
||||||
set->Assign(idx.get(), nullptr);
|
set->Assign(std::move(idx), nullptr);
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -475,7 +475,7 @@ function get_reporter_stats%(%): ReporterStats
|
||||||
for ( auto& kv : reporter->GetWeirdsByType() )
|
for ( auto& kv : reporter->GetWeirdsByType() )
|
||||||
{
|
{
|
||||||
auto weird = make_intrusive<StringVal>(kv.first);
|
auto weird = make_intrusive<StringVal>(kv.first);
|
||||||
weirds_by_type->Assign(weird.get(), val_mgr->Count(kv.second));
|
weirds_by_type->Assign(std::move(weird), val_mgr->Count(kv.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
r->Assign(n++, val_mgr->Count(reporter->GetWeirdCount()));
|
r->Assign(n++, val_mgr->Count(reporter->GetWeirdCount()));
|
||||||
|
|
|
@ -287,7 +287,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, int incl_sep, int max_num_sep)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ind = val_mgr->Count(++num);
|
auto ind = val_mgr->Count(++num);
|
||||||
a->Assign(ind.get(), make_intrusive<StringVal>(offset, (const char*) s));
|
a->Assign(std::move(ind), make_intrusive<StringVal>(offset, (const char*) s));
|
||||||
|
|
||||||
// No more separators will be needed if this is the end of string.
|
// No more separators will be needed if this is the end of string.
|
||||||
if ( n <= 0 )
|
if ( n <= 0 )
|
||||||
|
@ -296,7 +296,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, int incl_sep, int max_num_sep)
|
||||||
if ( incl_sep )
|
if ( incl_sep )
|
||||||
{ // including the part that matches the pattern
|
{ // including the part that matches the pattern
|
||||||
ind = val_mgr->Count(++num);
|
ind = val_mgr->Count(++num);
|
||||||
a->Assign(ind.get(), make_intrusive<StringVal>(end_of_match, (const char*) s+offset));
|
a->Assign(std::move(ind), make_intrusive<StringVal>(end_of_match, (const char*) s+offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( max_num_sep && num_sep >= max_num_sep )
|
if ( max_num_sep && num_sep >= max_num_sep )
|
||||||
|
@ -919,7 +919,7 @@ function find_all%(str: string, re: pattern%) : string_set
|
||||||
if ( n >= 0 )
|
if ( n >= 0 )
|
||||||
{
|
{
|
||||||
auto idx = make_intrusive<StringVal>(n, (const char*) t);
|
auto idx = make_intrusive<StringVal>(n, (const char*) t);
|
||||||
a->Assign(idx.get(), 0);
|
a->Assign(std::move(idx), 0);
|
||||||
t += n - 1;
|
t += n - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1150,7 +1150,7 @@ IntrusivePtr<RecordVal> Supervisor::NodeConfig::ToRecord() const
|
||||||
if ( ep.interface )
|
if ( ep.interface )
|
||||||
val->Assign(ept->FieldOffset("interface"), make_intrusive<StringVal>(*ep.interface));
|
val->Assign(ept->FieldOffset("interface"), make_intrusive<StringVal>(*ep.interface));
|
||||||
|
|
||||||
cluster_val->Assign(key.get(), std::move(val));
|
cluster_val->Assign(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
@ -1228,7 +1228,7 @@ bool Supervisor::SupervisedNode::InitCluster() const
|
||||||
val->Assign(cluster_node_type->FieldOffset("manager"),
|
val->Assign(cluster_node_type->FieldOffset("manager"),
|
||||||
make_intrusive<StringVal>(*manager_name));
|
make_intrusive<StringVal>(*manager_name));
|
||||||
|
|
||||||
cluster_nodes->Assign(key.get(), std::move(val));
|
cluster_nodes->Assign(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster_manager_is_logger_id->SetVal(val_mgr->Bool(! has_logger));
|
cluster_manager_is_logger_id->SetVal(val_mgr->Bool(! has_logger));
|
||||||
|
@ -1327,7 +1327,7 @@ IntrusivePtr<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(), std::move(val));
|
node_table_val->Assign(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1341,7 +1341,7 @@ IntrusivePtr<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(), std::move(val));
|
node_table_val->Assign(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -1925,7 +1925,7 @@ function global_sizes%(%): var_sizes
|
||||||
{
|
{
|
||||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||||
auto id_size = val_mgr->Count(id->GetVal()->MemoryAllocation());
|
auto id_size = val_mgr->Count(id->GetVal()->MemoryAllocation());
|
||||||
sizes->Assign(id_name.get(), std::move(id_size));
|
sizes->Assign(std::move(id_name), std::move(id_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,7 +1962,7 @@ function global_ids%(%): id_table
|
||||||
rec->Assign(6, id->GetVal());
|
rec->Assign(6, id->GetVal());
|
||||||
|
|
||||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||||
ids->Assign(id_name.get(), std::move(rec));
|
ids->Assign(std::move(id_name), std::move(rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids;
|
return ids;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue