Val: use class IntrusivePtr in class TableVal

This commit is contained in:
Max Kellermann 2020-03-02 19:41:38 +01:00
parent 93c2064b9a
commit 674e141a15
27 changed files with 88 additions and 109 deletions

View file

@ -952,7 +952,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
n = *kp;
kp1 = reinterpret_cast<const char*>(kp+1);
TableType* tt = t->AsTableType();
auto tv = make_intrusive<TableVal>(tt);
auto tv = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
vector<Val*> keys, values;
for ( int i = 0; i < n; ++i )
{

View file

@ -366,7 +366,7 @@ RecordVal* Connection::BuildConnVal()
conn_val->Assign(1, std::move(orig_endp));
conn_val->Assign(2, std::move(resp_endp));
// 3 and 4 are set below.
conn_val->Assign(5, make_intrusive<TableVal>(string_set)); // service
conn_val->Assign(5, make_intrusive<TableVal>(IntrusivePtr{NewRef{}, string_set})); // service
conn_val->Assign(6, val_mgr->GetEmptyString()); // history
if ( ! uid )

View file

@ -175,8 +175,8 @@ static TableVal* empty_addr_set()
BroType* addr_t = base_type(TYPE_ADDR);
TypeList* set_index = new TypeList(addr_t);
set_index->Append(addr_t);
SetType* s = new SetType(set_index, 0);
return new TableVal(s);
auto s = make_intrusive<SetType>(set_index, nullptr);
return new TableVal(std::move(s));
}
DNS_Mapping::DNS_Mapping(const char* host, struct hostent* h, uint32_t ttl)

View file

@ -3165,7 +3165,7 @@ IntrusivePtr<Val> TableConstructorExpr::Eval(Frame* f) const
if ( IsError() )
return nullptr;
auto aggr = make_intrusive<TableVal>(Type()->AsTableType(), attrs);
auto aggr = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, Type()->AsTableType()}, IntrusivePtr{NewRef{}, attrs});
const expr_list& exprs = op->AsListExpr()->Exprs();
for ( const auto& expr : exprs )
@ -3184,7 +3184,7 @@ IntrusivePtr<Val> TableConstructorExpr::InitVal(const BroType* t, IntrusivePtr<V
TableType* tt = Type()->AsTableType();
auto tval = aggr ?
IntrusivePtr<TableVal>{AdoptRef{}, aggr.release()->AsTableVal()} :
make_intrusive<TableVal>(tt, attrs);
make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt}, IntrusivePtr{NewRef{}, attrs});
const expr_list& exprs = op->AsListExpr()->Exprs();
for ( const auto& expr : exprs )
@ -3273,7 +3273,7 @@ IntrusivePtr<Val> SetConstructorExpr::Eval(Frame* f) const
if ( IsError() )
return nullptr;
auto aggr = make_intrusive<TableVal>(type->AsTableType(), attrs);
auto aggr = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, type->AsTableType()}, IntrusivePtr{NewRef{}, attrs});
const expr_list& exprs = op->AsListExpr()->Exprs();
for ( const auto& expr : exprs )
@ -3294,7 +3294,7 @@ IntrusivePtr<Val> SetConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val
TableType* tt = Type()->AsTableType();
auto tval = aggr ?
IntrusivePtr<TableVal>{AdoptRef{}, aggr.release()->AsTableVal()} :
make_intrusive<TableVal>(tt, attrs);
make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt}, IntrusivePtr{NewRef{}, attrs});
const expr_list& exprs = op->AsListExpr()->Exprs();
for ( const auto& e : exprs )
@ -3790,7 +3790,7 @@ IntrusivePtr<Val> TableCoerceExpr::Fold(Val* v) const
if ( tv->Size() > 0 )
RuntimeErrorWithCallStack("coercion of non-empty table/set");
return make_intrusive<TableVal>(Type()->AsTableType(), tv->Attrs());
return make_intrusive<TableVal>(IntrusivePtr{NewRef{}, Type()->AsTableType()}, IntrusivePtr{NewRef{}, tv->Attrs()});
}
VectorCoerceExpr::VectorCoerceExpr(IntrusivePtr<Expr> arg_op,

View file

@ -163,7 +163,7 @@ void ID::UpdateValAttrs()
return;
if ( val && val->Type()->Tag() == TYPE_TABLE )
val->AsTableVal()->SetAttrs(attrs.get());
val->AsTableVal()->SetAttrs(attrs);
if ( val && val->Type()->Tag() == TYPE_FILE )
val->AsFile()->SetAttrs(attrs.get());

View file

@ -345,7 +345,7 @@ SampleLogger::SampleLogger()
if ( ! load_sample_info )
load_sample_info = internal_type("load_sample_info")->AsTableType();
load_samples = new TableVal(load_sample_info);
load_samples = new TableVal({NewRef{}, load_sample_info});
}
SampleLogger::~SampleLogger()

View file

@ -1666,7 +1666,7 @@ IntrusivePtr<Val> InitStmt::Exec(Frame* f, stmt_flow_type& flow) const
v = new VectorVal(t->AsVectorType());
break;
case TYPE_TABLE:
v = new TableVal(t->AsTableType(), aggr->Attrs());
v = new TableVal({NewRef{}, t->AsTableType()}, {NewRef{}, aggr->Attrs()});
break;
default:
break;

View file

@ -808,7 +808,7 @@ static string container_type_name(const BroType* ft)
IntrusivePtr<TableVal> RecordType::GetRecordFieldsVal(const RecordVal* rv) const
{
auto rval = make_intrusive<TableVal>(internal_type("record_field_table")->AsTableType());
auto rval = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, internal_type("record_field_table")->AsTableType()});
for ( int i = 0; i < NumFields(); ++i )
{

View file

@ -410,7 +410,7 @@ IntrusivePtr<TableVal> Val::GetRecordFields()
if ( t->Tag() != TYPE_RECORD && t->Tag() != TYPE_TYPE )
{
reporter->Error("non-record value/type passed to record_fields");
return make_intrusive<TableVal>(internal_type("record_field_table")->AsTableType());
return make_intrusive<TableVal>(IntrusivePtr{NewRef{}, internal_type("record_field_table")->AsTableType()});
}
RecordType* rt = nullptr;
@ -428,7 +428,7 @@ IntrusivePtr<TableVal> Val::GetRecordFields()
if ( t->Tag() != TYPE_RECORD )
{
reporter->Error("non-record value/type passed to record_fields");
return make_intrusive<TableVal>(internal_type("record_field_table")->AsTableType());
return make_intrusive<TableVal>(IntrusivePtr{NewRef{}, internal_type("record_field_table")->AsTableType()});
}
rt = t->AsRecordType();
@ -1236,13 +1236,12 @@ TableVal* ListVal::ConvertToSet() const
TypeList* set_index = new TypeList(type->AsTypeList()->PureType());
set_index->Append(base_type(tag));
SetType* s = new SetType(set_index, 0);
TableVal* t = new TableVal(s);
auto s = make_intrusive<SetType>(set_index, nullptr);
TableVal* t = new TableVal(std::move(s));
for ( const auto& val : vals )
t->Assign(val, 0);
Unref(s);
return t;
}
@ -1326,23 +1325,22 @@ static void table_entry_val_delete_func(void* val)
delete tv;
}
TableVal::TableVal(TableType* t, Attributes* a) : Val(t)
TableVal::TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> a) : Val(t.get())
{
Init(t);
SetAttrs(a);
Init(std::move(t));
SetAttrs(std::move(a));
}
void TableVal::Init(TableType* t)
void TableVal::Init(IntrusivePtr<TableType> t)
{
::Ref(t);
table_type = t;
table_type = std::move(t);
expire_func = 0;
expire_time = 0;
expire_cookie = 0;
timer = 0;
def_val = 0;
if ( t->IsSubNetIndex() )
if ( table_type->IsSubNetIndex() )
subnets = new PrefixTable;
else
subnets = 0;
@ -1358,15 +1356,9 @@ TableVal::~TableVal()
if ( timer )
timer_mgr->Cancel(timer);
Unref(table_type);
delete table_hash;
delete AsTable();
delete subnets;
Unref(attrs);
Unref(def_val);
Unref(expire_func);
Unref(expire_time);
Unref(change_func);
}
void TableVal::RemoveAll()
@ -1404,15 +1396,13 @@ int TableVal::RecursiveSize() const
return n;
}
void TableVal::SetAttrs(Attributes* a)
void TableVal::SetAttrs(IntrusivePtr<Attributes> a)
{
attrs = a;
attrs = std::move(a);
if ( ! a )
if ( ! attrs )
return;
::Ref(attrs);
CheckExpireAttr(ATTR_EXPIRE_READ);
CheckExpireAttr(ATTR_EXPIRE_WRITE);
CheckExpireAttr(ATTR_EXPIRE_CREATE);
@ -1420,14 +1410,12 @@ void TableVal::SetAttrs(Attributes* a)
Attr* ef = attrs->FindAttr(ATTR_EXPIRE_FUNC);
if ( ef )
{
expire_func = ef->AttrExpr();
expire_func->Ref();
expire_func = {NewRef{}, ef->AttrExpr()};
}
auto cf = attrs->FindAttr(ATTR_ON_CHANGE);
if ( cf )
{
change_func = cf->AttrExpr();
change_func->Ref();
change_func = {NewRef{}, cf->AttrExpr()};
}
}
@ -1437,8 +1425,7 @@ void TableVal::CheckExpireAttr(attr_tag at)
if ( a )
{
expire_time = a->AttrExpr();
expire_time->Ref();
expire_time = {NewRef{}, a->AttrExpr()};
if ( expire_time->Type()->Tag() != TYPE_INTERVAL )
{
@ -1772,11 +1759,11 @@ IntrusivePtr<Val> TableVal::Default(Val* index)
auto coerce = make_intrusive<RecordCoerceExpr>(
IntrusivePtr{NewRef{}, def_attr->AttrExpr()},
IntrusivePtr{NewRef{}, ytype->AsRecordType()});
def_val = coerce->Eval(0).release();
def_val = coerce->Eval(0);
}
else
def_val = def_attr->AttrExpr()->Eval(0).release();
def_val = def_attr->AttrExpr()->Eval(0);
}
if ( ! def_val )
@ -1789,7 +1776,7 @@ IntrusivePtr<Val> TableVal::Default(Val* index)
same_type(def_val->Type(), Type()->YieldType()) )
{
if ( def_attr->AttrExpr()->IsConst() )
return {NewRef{}, def_val};
return def_val;
try
{
@ -1900,7 +1887,7 @@ IntrusivePtr<TableVal> TableVal::LookupSubnetValues(const SubNetVal* search)
if ( ! subnets )
reporter->InternalError("LookupSubnetValues called on wrong table type");
auto nt = make_intrusive<TableVal>(this->Type()->Ref()->AsTableType());
auto nt = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, this->Type()->AsTableType()});
auto matches = subnets->FindAll(search);
for ( auto element : matches )
@ -2252,7 +2239,7 @@ void TableVal::InitDefaultFunc(Frame* f)
ytype->AsRecordType()) )
return; // TableVal::Default will handle this.
def_val = def_attr->AttrExpr()->Eval(f).release();
def_val = def_attr->AttrExpr()->Eval(f);
}
void TableVal::InitTimer(double delay)
@ -2497,15 +2484,11 @@ IntrusivePtr<Val> TableVal::DoClone(CloneState* state)
delete key;
}
if ( attrs )
{
::Ref(attrs);
tv->attrs = attrs;
}
tv->attrs = attrs;
if ( expire_time )
{
tv->expire_time = expire_time->Ref();
tv->expire_time = expire_time;
// As network_time is not necessarily initialized yet, we set
// a timer which fires immediately.
@ -2514,10 +2497,10 @@ IntrusivePtr<Val> TableVal::DoClone(CloneState* state)
}
if ( expire_func )
tv->expire_func = expire_func->Ref();
tv->expire_func = expire_func;
if ( def_val )
tv->def_val = def_val->Clone().release();
tv->def_val = def_val->Clone();
return tv;
}
@ -2591,7 +2574,7 @@ RecordVal::RecordVal(RecordType* t, bool init_fields) : Val(t)
def = make_intrusive<RecordVal>(type->AsRecordType());
else if ( tag == TYPE_TABLE )
def = make_intrusive<TableVal>(type->AsTableType(), a);
def = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, type->AsTableType()}, IntrusivePtr{NewRef{}, a});
else if ( tag == TYPE_VECTOR )
def = make_intrusive<VectorVal>(type->AsVectorType());

View file

@ -693,7 +693,7 @@ class Frame;
class TableVal : public Val, public notifier::Modifiable {
public:
explicit TableVal(TableType* t, Attributes* attrs = 0);
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> attrs = nullptr);
~TableVal() override;
// Returns true if the assignment typechecked, false if not. The
@ -776,9 +776,9 @@ public:
ListVal* ConvertToList(TypeTag t=TYPE_ANY) const;
ListVal* ConvertToPureList() const; // must be single index type
void SetAttrs(Attributes* attrs);
void SetAttrs(IntrusivePtr<Attributes> attrs);
Attr* FindAttr(attr_tag t) const;
Attributes* Attrs() { return attrs; }
Attributes* Attrs() { return attrs.get(); }
// Returns the size of the table.
int Size() const;
@ -812,7 +812,7 @@ public:
notifier::Modifiable* Modifiable() override { return this; }
protected:
void Init(TableType* t);
void Init(IntrusivePtr<TableType> t);
void CheckExpireAttr(attr_tag at);
int ExpandCompoundAndInit(val_list* vl, int k, IntrusivePtr<Val> new_val);
@ -841,16 +841,16 @@ protected:
IntrusivePtr<Val> DoClone(CloneState* state) override;
TableType* table_type;
IntrusivePtr<TableType> table_type;
CompositeHash* table_hash;
Attributes* attrs;
Expr* expire_time;
Expr* expire_func;
IntrusivePtr<Attributes> attrs;
IntrusivePtr<Expr> expire_time;
IntrusivePtr<Expr> expire_func;
TableValTimer* timer;
IterCookie* expire_cookie;
PrefixTable* subnets;
Val* def_val;
Expr* change_func = nullptr;
IntrusivePtr<Val> def_val;
IntrusivePtr<Expr> change_func;
// prevent recursion of change functions
bool in_change_func = false;
};

View file

@ -168,7 +168,7 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
}
else if ( t->Tag() == TYPE_TABLE )
aggr = make_intrusive<TableVal>(t->AsTableType(), id->Attrs());
aggr = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, t->AsTableType()}, IntrusivePtr{NewRef{}, id->Attrs()});
else if ( t->Tag() == TYPE_VECTOR )
aggr = make_intrusive<VectorVal>(t->AsVectorType());

View file

@ -45,7 +45,7 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
req_buf_pos = req_buf;
req_buf_len = 0;
req_val_uri = 0;
req_val_headers = new TableVal(bt_tracker_headers);
req_val_headers = new TableVal({NewRef{}, bt_tracker_headers});
res_state = BTT_RES_STATUS;
res_allow_blank_line = false;
@ -53,9 +53,9 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
res_buf_pos = res_buf;
res_buf_len = 0;
res_status = 0;
res_val_headers = new TableVal(bt_tracker_headers);
res_val_peers = new TableVal(bittorrent_peer_set);
res_val_benc = new TableVal(bittorrent_benc_dir);
res_val_headers = new TableVal({NewRef{}, bt_tracker_headers});
res_val_peers = new TableVal({NewRef{}, bittorrent_peer_set});
res_val_benc = new TableVal({NewRef{}, bittorrent_benc_dir});
InitBencParser();
@ -137,7 +137,7 @@ void BitTorrentTracker_Analyzer::ClientRequest(int len, const u_char* data)
memmove(req_buf, req_buf_pos, req_buf_len);
req_buf_pos = req_buf;
req_val_headers =
new TableVal(bt_tracker_headers);
new TableVal({NewRef{}, bt_tracker_headers});
}
}
}
@ -199,9 +199,9 @@ void BitTorrentTracker_Analyzer::ServerReply(int len, const u_char* data)
res_buf_pos = res_buf;
res_status = 0;
res_val_headers = new TableVal(bt_tracker_headers);
res_val_peers = new TableVal(bittorrent_peer_set);
res_val_benc = new TableVal(bittorrent_benc_dir);
res_val_headers = new TableVal({NewRef{}, bt_tracker_headers});
res_val_peers = new TableVal({NewRef{}, bittorrent_peer_set});
res_val_benc = new TableVal({NewRef{}, bittorrent_benc_dir});
InitBencParser();
}

View file

@ -270,7 +270,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
if ( parts.size() > 0 && parts[0][0] == ':' )
parts[0] = parts[0].substr(1);
TableVal* set = new TableVal(string_set);
TableVal* set = new TableVal({NewRef{}, string_set});
for ( unsigned int i = 0; i < parts.size(); ++i )
{
@ -463,7 +463,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
if ( parts.size() > 0 && parts[0][0] == ':' )
parts[0] = parts[0].substr(1);
TableVal* set = new TableVal(string_set);
TableVal* set = new TableVal({NewRef{}, string_set});
for ( unsigned int i = 0; i < parts.size(); ++i )
{
@ -841,7 +841,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
nickname = prefix.substr(0, pos);
}
TableVal* list = new TableVal(irc_join_list);
TableVal* list = new TableVal({NewRef{}, irc_join_list});
vector<string> channels = SplitWords(parts[0], ',');
vector<string> passwords;
@ -886,7 +886,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
parts[1] = parts[1].substr(1);
vector<string> users = SplitWords(parts[1], ',');
TableVal* list = new TableVal(irc_join_list);
TableVal* list = new TableVal({NewRef{}, irc_join_list});
string empty_string = "";
@ -957,7 +957,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
nick = nick.substr(0, pos);
vector<string> channelList = SplitWords(channels, ',');
TableVal* set = new TableVal(string_set);
TableVal* set = new TableVal({NewRef{}, string_set});
for ( unsigned int i = 0; i < channelList.size(); ++i )
{

View file

@ -1299,7 +1299,7 @@ RecordVal* MIME_Message::BuildHeaderVal(MIME_Header* h)
TableVal* MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
{
TableVal* t = new TableVal(mime_header_list);
TableVal* t = new TableVal({NewRef{}, mime_header_list});
for ( unsigned int i = 0; i < hlist.size(); ++i )
{

View file

@ -14,7 +14,7 @@ refine flow RADIUS_Flow += {
if ( ${msg.attributes}->size() )
{
TableVal* attributes = new TableVal(BifType::Table::RADIUS::Attributes);
TableVal* attributes = new TableVal({NewRef{}, BifType::Table::RADIUS::Attributes});
for ( uint i = 0; i < ${msg.attributes}->size(); ++i ) {
Val* index = val_mgr->GetCount(${msg.attributes[i].code});

View file

@ -139,7 +139,7 @@ int PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status status
event = success ? pm_request_dump : pm_attempt_dump;
if ( success )
{
TableVal* mappings = new TableVal(pm_mappings);
TableVal* mappings = new TableVal({NewRef{}, pm_mappings});
uint32_t nmap = 0;
// Each call in the loop test pulls the next "opted"

View file

@ -65,7 +65,7 @@ refine flow SIP_Flow += {
function build_sip_headers_val(): BroVal
%{
TableVal* t = new TableVal(mime_header_list);
TableVal* t = new TableVal({NewRef{}, mime_header_list});
for ( unsigned int i = 0; i < headers.size(); ++i )
{ // index starting from 1

View file

@ -208,7 +208,7 @@ struct val_converter {
return nullptr;
auto tt = type->AsTableType();
auto rval = make_intrusive<TableVal>(tt);
auto rval = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
for ( auto& item : a )
{
@ -268,7 +268,7 @@ struct val_converter {
return nullptr;
auto tt = type->AsTableType();
auto rval = make_intrusive<TableVal>(tt);
auto rval = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
for ( auto& item : a )
{

View file

@ -25,10 +25,8 @@ static Val* empty_connection_table()
{
TypeList* tbl_index = new TypeList(conn_id);
tbl_index->Append(conn_id->Ref());
TableType* tbl_type = new TableType(tbl_index, connection_type->Ref());
Val* rval = new TableVal(tbl_type);
Unref(tbl_type);
return rval;
auto tbl_type = make_intrusive<TableType>(tbl_index, connection_type->Ref());
return new TableVal(std::move(tbl_type));
}
static RecordVal* get_conn_id_val(const Connection* conn)

View file

@ -25,7 +25,7 @@ refine flow File += {
function characteristics_to_bro(c: uint32, len: uint8): TableVal
%{
uint64 mask = (len==16) ? 0xFFFF : 0xFFFFFFFF;
TableVal* char_set = new TableVal(internal_type("count_set")->AsTableType());
TableVal* char_set = new TableVal({NewRef{}, internal_type("count_set")->AsTableType()});
for ( uint16 i=0; i < len; ++i )
{
if ( ((c >> i) & 0x1) == 1 )

View file

@ -2379,8 +2379,8 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
BroType* type = request_type->AsTableType()->Indices()->PureType();
TypeList* set_index = new TypeList(type->Ref());
set_index->Append(type->Ref());
SetType* s = new SetType(set_index, 0);
TableVal* t = new TableVal(s);
auto s = make_intrusive<SetType>(set_index, nullptr);
TableVal* t = new TableVal(std::move(s));
for ( int j = 0; j < val->val.set_val.size; j++ )
{
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type, have_error);
@ -2389,7 +2389,6 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
Unref(assignval); // index is not consumed by assign.
}
Unref(s);
return t;
}
@ -2562,8 +2561,8 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
set_index->Append(index_type->Ref());
}
SetType* s = new SetType(set_index, 0);
TableVal* t = new TableVal(s);
auto s = make_intrusive<SetType>(set_index, nullptr);
TableVal* t = new TableVal(std::move(s));
for ( int j = 0; j < val->val.set_val.size; j++ )
{
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], have_error);
@ -2572,7 +2571,6 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
Unref(assignval); // index is not consumed by assign.
}
Unref(s);
return t;
}

View file

@ -101,8 +101,8 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
val->Type()->AsTableType()->IsUnspecifiedTable() )
{
// Just coerce an empty/unspecified table to the right type.
auto tv = new TableVal(i->Type()->AsTableType(),
i->ID_Val()->AsTableVal()->Attrs());
auto tv = new TableVal({NewRef{}, i->Type()->AsTableType()},
{NewRef{}, i->ID_Val()->AsTableVal()->Attrs()});
auto rval = call_option_handlers_and_set_value(ID, i, tv, location);
Unref(tv);
return val_mgr->GetBool(rval);

View file

@ -153,7 +153,7 @@ function Reporter::file_weird%(name: string, f: fa_file, addl: string &default="
## Returns: Current weird sampling whitelist
function Reporter::get_weird_sampling_whitelist%(%): string_set
%{
TableVal* set = new TableVal(string_set);
TableVal* set = new TableVal({NewRef{}, string_set});
for ( auto el : reporter->GetWeirdSamplingWhitelist() )
{
auto idx = make_intrusive<StringVal>(el);

View file

@ -470,7 +470,7 @@ function get_reporter_stats%(%): ReporterStats
RecordVal* r = new RecordVal(ReporterStats);
int n = 0;
TableVal* weirds_by_type = new TableVal(internal_type("table_string_of_count")->AsTableType());
TableVal* weirds_by_type = new TableVal({NewRef{}, internal_type("table_string_of_count")->AsTableType()});
for ( auto& kv : reporter->GetWeirdsByType() )
{

View file

@ -294,7 +294,7 @@ VectorVal* do_split_string(StringVal* str_val, RE_Matcher* re, int incl_sep,
Val* do_split(StringVal* str_val, RE_Matcher* re, int incl_sep, int max_num_sep)
{
TableVal* a = new TableVal(string_array);
TableVal* a = new TableVal({NewRef{}, string_array});
const u_char* s = str_val->Bytes();
int n = str_val->Len();
const u_char* end_of_s = s + n;
@ -946,7 +946,7 @@ function safe_shell_quote%(source: string%): string
## .. zeek:see: find_last strstr
function find_all%(str: string, re: pattern%) : string_set
%{
TableVal* a = new TableVal(string_set);
TableVal* a = new TableVal({NewRef{}, string_set});
const u_char* s = str->Bytes();
const u_char* e = s + str->Len();

View file

@ -1131,7 +1131,7 @@ IntrusivePtr<RecordVal> Supervisor::NodeConfig::ToRecord() const
scripts_val->Assign(scripts_val->Size(), make_intrusive<StringVal>(s));
auto tt = BifType::Record::Supervisor::NodeConfig->FieldType("cluster");
auto cluster_val = new TableVal(tt->AsTableType());
auto cluster_val = new TableVal({NewRef{}, tt->AsTableType()});
rval->Assign(rt->FieldOffset("cluster"), cluster_val);
for ( const auto& e : cluster )
@ -1315,7 +1315,7 @@ RecordVal* Supervisor::Status(std::string_view node_name)
{
auto rval = new RecordVal(BifType::Record::Supervisor::Status);
auto tt = BifType::Record::Supervisor::Status->FieldType("nodes");
auto node_table_val = new TableVal(tt->AsTableType());
auto node_table_val = new TableVal({NewRef{}, tt->AsTableType()});
rval->Assign(0, node_table_val);
if ( node_name.empty() )

View file

@ -1919,7 +1919,7 @@ function packet_source%(%): PacketSource
## .. zeek:see:: global_ids
function global_sizes%(%): var_sizes
%{
TableVal* sizes = new TableVal(var_sizes);
TableVal* sizes = new TableVal({NewRef{}, var_sizes});
const auto& globals = global_scope()->Vars();
for ( const auto& global : globals )
@ -1947,7 +1947,7 @@ function global_sizes%(%): var_sizes
## .. zeek:see:: global_sizes
function global_ids%(%): id_table
%{
TableVal* ids = new TableVal(id_table);
TableVal* ids = new TableVal({NewRef{}, id_table});
const auto& globals = global_scope()->Vars();
for ( const auto& global : globals )
@ -2009,7 +2009,7 @@ function record_fields%(rec: any%): record_field_table
if ( ! id || ! id->AsType() || id->AsType()->Tag() != TYPE_RECORD )
{
reporter->Error("record_fields string argument does not name a record type");
return new TableVal(internal_type("record_field_table")->AsTableType());
return new TableVal({NewRef{}, internal_type("record_field_table")->AsTableType()});
}
return id->AsType()->AsRecordType()->GetRecordFieldsVal().release();
@ -3327,7 +3327,7 @@ function lookup_connection%(cid: conn_id%): connection
c->Assign(3, make_intrusive<Val>(network_time, TYPE_TIME));
c->Assign(4, make_intrusive<Val>(0.0, TYPE_INTERVAL));
c->Assign(5, make_intrusive<TableVal>(string_set)); // service
c->Assign(5, make_intrusive<TableVal>(IntrusivePtr{NewRef{}, string_set})); // service
c->Assign(6, val_mgr->GetEmptyString()); // history
return c;