mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Update various BIFs to return IntrusivePtr
This commit is contained in:
parent
17f72d6be6
commit
9e56881c70
9 changed files with 72 additions and 78 deletions
|
@ -94,7 +94,7 @@ function Broker::__unpeer%(a: string, p: port%): bool
|
|||
function Broker::__peers%(%): PeerInfos
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
VectorVal* rval = new VectorVal(internal_type("Broker::PeerInfos")->AsVectorType());
|
||||
auto rval = make_intrusive<VectorVal>(internal_type("Broker::PeerInfos")->AsVectorType());
|
||||
auto i = 0;
|
||||
|
||||
for ( auto& p : broker_mgr->Peers() )
|
||||
|
|
|
@ -146,7 +146,7 @@ function Broker::__set_iterator_next%(it: opaque of Broker::SetIterator%): bool
|
|||
function Broker::__set_iterator_value%(it: opaque of Broker::SetIterator%): Broker::Data
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto rval = make_intrusive<RecordVal>(BifType::Record::Broker::Data);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ function Broker::__table_iterator_next%(it: opaque of Broker::TableIterator%): b
|
|||
function Broker::__table_iterator_value%(it: opaque of Broker::TableIterator%): Broker::TableItem
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::TableItem);
|
||||
auto rval = make_intrusive<RecordVal>(BifType::Record::Broker::TableItem);
|
||||
auto key_val = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto val_val = new RecordVal(BifType::Record::Broker::Data);
|
||||
rval->Assign(0, key_val);
|
||||
|
@ -423,7 +423,7 @@ function Broker::__vector_iterator_next%(it: opaque of Broker::VectorIterator%):
|
|||
function Broker::__vector_iterator_value%(it: opaque of Broker::VectorIterator%): Broker::Data
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto rval = make_intrusive<RecordVal>(BifType::Record::Broker::Data);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
{
|
||||
|
@ -502,7 +502,7 @@ function Broker::__record_iterator_next%(it: opaque of Broker::RecordIterator%):
|
|||
function Broker::__record_iterator_value%(it: opaque of Broker::RecordIterator%): Broker::Data
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto rval = make_intrusive<RecordVal>(BifType::Record::Broker::Data);
|
||||
|
||||
if ( ri->it == ri->dat.end() )
|
||||
{
|
||||
|
|
|
@ -89,8 +89,7 @@ function Broker::make_event%(...%): Broker::Event
|
|||
for ( auto i = 0u; i < bif_args->size(); ++i )
|
||||
args.push_back((*bif_args)[i].get());
|
||||
|
||||
auto rval = broker_mgr->MakeEvent(&args, frame);
|
||||
return rval;
|
||||
return IntrusivePtr<RecordVal>{AdoptRef{}, broker_mgr->MakeEvent(&args, frame)};
|
||||
%}
|
||||
|
||||
## Publishes an event at a given topic.
|
||||
|
|
|
@ -42,16 +42,13 @@ function Broker::__create_master%(id: string, b: BackendType,
|
|||
auto rval = broker_mgr->LookupStore(name);
|
||||
|
||||
if ( rval )
|
||||
{
|
||||
::Ref(rval);
|
||||
return rval;
|
||||
}
|
||||
return IntrusivePtr<Val>{NewRef{}, rval};
|
||||
|
||||
auto e = static_cast<BifEnum::Broker::BackendType>(b->AsEnum());
|
||||
auto type = bro_broker::to_backend_type(e);
|
||||
auto opts = bro_broker::to_backend_options(type, options->AsRecordVal());
|
||||
|
||||
auto store = broker_mgr->MakeMaster(name, type, std::move(opts));
|
||||
IntrusivePtr<Val> store{AdoptRef{}, broker_mgr->MakeMaster(name, type, std::move(opts))};
|
||||
|
||||
if ( ! store )
|
||||
{
|
||||
|
@ -71,13 +68,13 @@ function Broker::__create_clone%(id: string, resync_interval: interval,
|
|||
auto rval = broker_mgr->LookupStore(name);
|
||||
|
||||
if ( rval )
|
||||
{
|
||||
::Ref(rval);
|
||||
return rval;
|
||||
}
|
||||
return IntrusivePtr<Val>{NewRef{}, rval};
|
||||
|
||||
IntrusivePtr<Val> store {AdoptRef{},
|
||||
broker_mgr->MakeClone(name, resync_interval,
|
||||
stale_interval,
|
||||
mutation_buffer_interval)};
|
||||
|
||||
auto store = broker_mgr->MakeClone(name, resync_interval, stale_interval,
|
||||
mutation_buffer_interval);
|
||||
if ( ! store )
|
||||
{
|
||||
builtin_error(fmt("Could not create clone of Broker store '%s'", name));
|
||||
|
|
|
@ -23,7 +23,7 @@ module GLOBAL;
|
|||
function hll_cardinality_init%(err: double, confidence: double%): opaque of cardinality
|
||||
%{
|
||||
CardinalityCounter* c = new CardinalityCounter(err, confidence);
|
||||
CardinalityVal* cv = new CardinalityVal(c);
|
||||
auto cv = make_intrusive<CardinalityVal>(c);
|
||||
|
||||
return cv;
|
||||
%}
|
||||
|
@ -129,7 +129,7 @@ function hll_cardinality_copy%(handle: opaque of cardinality%): opaque of cardin
|
|||
CardinalityVal* cv = static_cast<CardinalityVal*>(handle);
|
||||
CardinalityCounter* h = cv->Get();
|
||||
CardinalityCounter* h2 = new CardinalityCounter(*h);
|
||||
CardinalityVal* out = new CardinalityVal(h2);
|
||||
auto out = make_intrusive<CardinalityVal>(h2);
|
||||
|
||||
return out;
|
||||
%}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
## topk_size topk_sum topk_merge topk_merge_prune
|
||||
function topk_init%(size: count%): opaque of topk
|
||||
%{
|
||||
probabilistic::TopkVal* v = new probabilistic::TopkVal(size);
|
||||
auto v = make_intrusive<probabilistic::TopkVal>(size);
|
||||
return v;
|
||||
%}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ function get_net_stats%(%): NetStats
|
|||
bytes_recv += stat.bytes_received;
|
||||
}
|
||||
|
||||
RecordVal* r = new RecordVal(NetStats);
|
||||
auto r = make_intrusive<RecordVal>(NetStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(recv));
|
||||
|
@ -83,7 +83,7 @@ function get_net_stats%(%): NetStats
|
|||
## get_reporter_stats
|
||||
function get_conn_stats%(%): ConnStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(ConnStats);
|
||||
auto r = make_intrusive<RecordVal>(ConnStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(Connection::TotalConnections()));
|
||||
|
@ -137,7 +137,7 @@ function get_proc_stats%(%): ProcStats
|
|||
if ( getrusage(RUSAGE_SELF, &ru) < 0 )
|
||||
reporter->InternalError("getrusage() failed in get_proc_stats()");
|
||||
|
||||
RecordVal* r = new RecordVal(ProcStats);
|
||||
auto r = make_intrusive<RecordVal>(ProcStats);
|
||||
int n = 0;
|
||||
|
||||
double elapsed_time = current_time() - bro_start_time;
|
||||
|
@ -190,7 +190,7 @@ function get_proc_stats%(%): ProcStats
|
|||
## get_reporter_stats
|
||||
function get_event_stats%(%): EventStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(EventStats);
|
||||
auto r = make_intrusive<RecordVal>(EventStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(num_events_queued));
|
||||
|
@ -217,7 +217,7 @@ function get_event_stats%(%): EventStats
|
|||
## get_reporter_stats
|
||||
function get_reassembler_stats%(%): ReassemblerStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(ReassemblerStats);
|
||||
auto r = make_intrusive<RecordVal>(ReassemblerStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(Reassembler::MemoryAllocation(REASSEM_FILE)));
|
||||
|
@ -246,7 +246,7 @@ function get_reassembler_stats%(%): ReassemblerStats
|
|||
## get_reporter_stats
|
||||
function get_dns_stats%(%): DNSStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(DNSStats);
|
||||
auto r = make_intrusive<RecordVal>(DNSStats);
|
||||
int n = 0;
|
||||
|
||||
DNS_Mgr::Stats dstats;
|
||||
|
@ -280,7 +280,7 @@ function get_dns_stats%(%): DNSStats
|
|||
## get_reporter_stats
|
||||
function get_timer_stats%(%): TimerStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(TimerStats);
|
||||
auto r = make_intrusive<RecordVal>(TimerStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(unsigned(timer_mgr->Size())));
|
||||
|
@ -308,7 +308,7 @@ function get_timer_stats%(%): TimerStats
|
|||
## get_reporter_stats
|
||||
function get_file_analysis_stats%(%): FileAnalysisStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(FileAnalysisStats);
|
||||
auto r = make_intrusive<RecordVal>(FileAnalysisStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(file_mgr->CurrentFiles()));
|
||||
|
@ -336,7 +336,7 @@ function get_file_analysis_stats%(%): FileAnalysisStats
|
|||
## get_reporter_stats
|
||||
function get_thread_stats%(%): ThreadStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(ThreadStats);
|
||||
auto r = make_intrusive<RecordVal>(ThreadStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(thread_mgr->NumThreads()));
|
||||
|
@ -362,7 +362,7 @@ function get_thread_stats%(%): ThreadStats
|
|||
## get_reporter_stats
|
||||
function get_gap_stats%(%): GapStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(GapStats);
|
||||
auto r = make_intrusive<RecordVal>(GapStats);
|
||||
int n = 0;
|
||||
|
||||
r->Assign(n++, val_mgr->Count(tot_ack_events));
|
||||
|
@ -394,7 +394,7 @@ function get_gap_stats%(%): GapStats
|
|||
## get_reporter_stats
|
||||
function get_matcher_stats%(%): MatcherStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(MatcherStats);
|
||||
auto r = make_intrusive<RecordVal>(MatcherStats);
|
||||
int n = 0;
|
||||
|
||||
RuleMatcher::Stats s;
|
||||
|
@ -432,7 +432,7 @@ function get_matcher_stats%(%): MatcherStats
|
|||
## get_reporter_stats
|
||||
function get_broker_stats%(%): BrokerStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(BrokerStats);
|
||||
auto r = make_intrusive<RecordVal>(BrokerStats);
|
||||
int n = 0;
|
||||
|
||||
auto cs = broker_mgr->GetStatistics();
|
||||
|
@ -467,16 +467,15 @@ function get_broker_stats%(%): BrokerStats
|
|||
## get_broker_stats
|
||||
function get_reporter_stats%(%): ReporterStats
|
||||
%{
|
||||
RecordVal* r = new RecordVal(ReporterStats);
|
||||
auto r = make_intrusive<RecordVal>(ReporterStats);
|
||||
int n = 0;
|
||||
|
||||
TableVal* weirds_by_type = new TableVal({NewRef{}, internal_type("table_string_of_count")->AsTableType()});
|
||||
|
||||
for ( auto& kv : reporter->GetWeirdsByType() )
|
||||
{
|
||||
Val* weird = new StringVal(kv.first);
|
||||
weirds_by_type->Assign(weird, val_mgr->Count(kv.second));
|
||||
Unref(weird);
|
||||
auto weird = make_intrusive<StringVal>(kv.first);
|
||||
weirds_by_type->Assign(weird.get(), val_mgr->Count(kv.second));
|
||||
}
|
||||
|
||||
r->Assign(n++, val_mgr->Count(reporter->GetWeirdCount()));
|
||||
|
|
|
@ -647,7 +647,7 @@ function is_ascii%(str: string%): bool
|
|||
function escape_string%(s: string%): string
|
||||
%{
|
||||
char* escstr = s->AsString()->Render(BroString::ESC_HEX | BroString::ESC_ESC);
|
||||
Val* val = new StringVal(escstr);
|
||||
auto val = make_intrusive<StringVal>(escstr);
|
||||
delete [] escstr;
|
||||
return val;
|
||||
%}
|
||||
|
@ -686,7 +686,7 @@ function str_smith_waterman%(s1: string, s2: string, params: sw_params%) : sw_su
|
|||
|
||||
BroSubstring::Vec* subseq =
|
||||
smith_waterman(s1->AsString(), s2->AsString(), sw_params);
|
||||
VectorVal* result = BroSubstring::VecToPolicy(subseq);
|
||||
auto result = IntrusivePtr<VectorVal>{AdoptRef{}, BroSubstring::VecToPolicy(subseq)};
|
||||
delete_each(subseq);
|
||||
delete subseq;
|
||||
|
||||
|
@ -713,7 +713,7 @@ function str_split%(s: string, idx: index_vec%): string_vec
|
|||
indices[i] = (*idx_v)[i]->AsCount();
|
||||
|
||||
BroString::Vec* result = s->AsString()->Split(indices);
|
||||
VectorVal* result_v = new VectorVal(
|
||||
auto result_v = make_intrusive<VectorVal>(
|
||||
internal_type("string_vec")->AsVectorType());
|
||||
|
||||
if ( result )
|
||||
|
@ -909,7 +909,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({NewRef{}, string_set});
|
||||
auto a = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, string_set});
|
||||
|
||||
const u_char* s = str->Bytes();
|
||||
const u_char* e = s + str->Len();
|
||||
|
@ -919,9 +919,8 @@ function find_all%(str: string, re: pattern%) : string_set
|
|||
int n = re->MatchPrefix(t, e - t);
|
||||
if ( n >= 0 )
|
||||
{
|
||||
Val* idx = new StringVal(n, (const char*) t);
|
||||
a->Assign(idx, 0);
|
||||
Unref(idx);
|
||||
auto idx = make_intrusive<StringVal>(n, (const char*) t);
|
||||
a->Assign(idx.get(), 0);
|
||||
t += n - 1;
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1067,7 @@ function hexdump%(data_str: string%) : string
|
|||
*ascii_ptr++ = '\n';
|
||||
*ascii_ptr = 0;
|
||||
|
||||
StringVal* result = new StringVal((const char*) hex_data);
|
||||
auto result = make_intrusive<StringVal>((const char*) hex_data);
|
||||
delete [] hex_data;
|
||||
|
||||
return result;
|
||||
|
|
66
src/zeek.bif
66
src/zeek.bif
|
@ -639,7 +639,7 @@ function md5_hmac%(...%): string
|
|||
## sha256_hash sha256_hash_init sha256_hash_update sha256_hash_finish
|
||||
function md5_hash_init%(%): opaque of md5
|
||||
%{
|
||||
HashVal* digest = new MD5Val();
|
||||
auto digest = make_intrusive<MD5Val>();
|
||||
digest->Init();
|
||||
return digest;
|
||||
%}
|
||||
|
@ -664,7 +664,7 @@ function md5_hash_init%(%): opaque of md5
|
|||
## sha256_hash sha256_hash_init sha256_hash_update sha256_hash_finish
|
||||
function sha1_hash_init%(%): opaque of sha1
|
||||
%{
|
||||
HashVal* digest = new SHA1Val();
|
||||
auto digest = make_intrusive<SHA1Val>();
|
||||
digest->Init();
|
||||
return digest;
|
||||
%}
|
||||
|
@ -689,7 +689,7 @@ function sha1_hash_init%(%): opaque of sha1
|
|||
## sha256_hash sha256_hash_update sha256_hash_finish
|
||||
function sha256_hash_init%(%): opaque of sha256
|
||||
%{
|
||||
HashVal* digest = new SHA256Val();
|
||||
auto digest = make_intrusive<SHA256Val>();
|
||||
digest->Init();
|
||||
return digest;
|
||||
%}
|
||||
|
@ -1050,7 +1050,7 @@ function find_entropy%(data: string%): entropy_test_result
|
|||
e.Feed(data->Bytes(), data->Len());
|
||||
e.Get(&ent, &chisq, &mean, &montepi, &scc);
|
||||
|
||||
RecordVal* ent_result = new RecordVal(entropy_test_result);
|
||||
auto ent_result = make_intrusive<RecordVal>(entropy_test_result);
|
||||
ent_result->Assign(0, make_intrusive<Val>(ent, TYPE_DOUBLE));
|
||||
ent_result->Assign(1, make_intrusive<Val>(chisq, TYPE_DOUBLE));
|
||||
ent_result->Assign(2, make_intrusive<Val>(mean, TYPE_DOUBLE));
|
||||
|
@ -1101,7 +1101,7 @@ function entropy_test_finish%(handle: opaque of entropy%): entropy_test_result
|
|||
montepi = scc = ent = mean = chisq = 0.0;
|
||||
static_cast<EntropyVal*>(handle)->Get(&ent, &chisq, &mean, &montepi, &scc);
|
||||
|
||||
RecordVal* ent_result = new RecordVal(entropy_test_result);
|
||||
auto ent_result = make_intrusive<RecordVal>(entropy_test_result);
|
||||
ent_result->Assign(0, make_intrusive<Val>(ent, TYPE_DOUBLE));
|
||||
ent_result->Assign(1, make_intrusive<Val>(chisq, TYPE_DOUBLE));
|
||||
ent_result->Assign(2, make_intrusive<Val>(mean, TYPE_DOUBLE));
|
||||
|
@ -1399,12 +1399,12 @@ bool indirect_unsigned_sort_function(size_t a, size_t b)
|
|||
## .. zeek:see:: order
|
||||
function sort%(v: any, ...%) : any
|
||||
%{
|
||||
v->Ref(); // we always return v
|
||||
IntrusivePtr<Val> rval{NewRef{}, v};
|
||||
|
||||
if ( v->Type()->Tag() != TYPE_VECTOR )
|
||||
{
|
||||
builtin_error("sort() requires vector");
|
||||
return v;
|
||||
return rval;
|
||||
}
|
||||
|
||||
BroType* elt_type = v->Type()->YieldType();
|
||||
|
@ -1419,7 +1419,7 @@ function sort%(v: any, ...%) : any
|
|||
if ( ! IsFunc(comp_val->Type()->Tag()) )
|
||||
{
|
||||
builtin_error("second argument to sort() needs to be comparison function");
|
||||
return v;
|
||||
return rval;
|
||||
}
|
||||
|
||||
comp = comp_val->AsFunc();
|
||||
|
@ -1437,7 +1437,7 @@ function sort%(v: any, ...%) : any
|
|||
! comp_type->ArgTypes()->AllMatch(elt_type, 0) )
|
||||
{
|
||||
builtin_error("invalid comparison function in call to sort()");
|
||||
return v;
|
||||
return rval;
|
||||
}
|
||||
|
||||
sort_function_comp = comp;
|
||||
|
@ -1452,7 +1452,7 @@ function sort%(v: any, ...%) : any
|
|||
sort(vv.begin(), vv.end(), signed_sort_function);
|
||||
}
|
||||
|
||||
return v;
|
||||
return rval;
|
||||
%}
|
||||
|
||||
## Returns the order of the elements in a vector according to some
|
||||
|
@ -1468,7 +1468,7 @@ function sort%(v: any, ...%) : any
|
|||
## .. zeek:see:: sort
|
||||
function order%(v: any, ...%) : index_vec
|
||||
%{
|
||||
VectorVal* result_v = new VectorVal(
|
||||
auto result_v = make_intrusive<VectorVal>(
|
||||
internal_type("index_vec")->AsVectorType());
|
||||
|
||||
if ( v->Type()->Tag() != TYPE_VECTOR )
|
||||
|
@ -1489,7 +1489,7 @@ function order%(v: any, ...%) : index_vec
|
|||
if ( ! IsFunc(comp_val->Type()->Tag()) )
|
||||
{
|
||||
builtin_error("second argument to order() needs to be comparison function");
|
||||
return v;
|
||||
return IntrusivePtr<Val>{NewRef{}, v};
|
||||
}
|
||||
|
||||
comp = comp_val->AsFunc();
|
||||
|
@ -1519,7 +1519,7 @@ function order%(v: any, ...%) : index_vec
|
|||
! comp_type->ArgTypes()->AllMatch(elt_type, 0) )
|
||||
{
|
||||
builtin_error("invalid comparison function in call to order()");
|
||||
return v;
|
||||
return IntrusivePtr<Val>{NewRef{}, v};
|
||||
}
|
||||
|
||||
sort_function_comp = comp;
|
||||
|
@ -1822,8 +1822,8 @@ function zeek_version%(%): string
|
|||
## Returns: A string vector with the field names of *rt*.
|
||||
function record_type_to_vector%(rt: string%): string_vec
|
||||
%{
|
||||
VectorVal* result =
|
||||
new VectorVal(internal_type("string_vec")->AsVectorType());
|
||||
auto result =
|
||||
make_intrusive<VectorVal>(internal_type("string_vec")->AsVectorType());
|
||||
|
||||
RecordType *type = internal_type(rt->CheckString())->AsRecordType();
|
||||
|
||||
|
@ -1916,7 +1916,7 @@ function packet_source%(%): PacketSource
|
|||
## .. zeek:see:: global_ids
|
||||
function global_sizes%(%): var_sizes
|
||||
%{
|
||||
TableVal* sizes = new TableVal({NewRef{}, var_sizes});
|
||||
auto sizes = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, var_sizes});
|
||||
const auto& globals = global_scope()->Vars();
|
||||
|
||||
for ( const auto& global : globals )
|
||||
|
@ -1924,10 +1924,9 @@ function global_sizes%(%): var_sizes
|
|||
ID* id = global.second.get();
|
||||
if ( id->HasVal() )
|
||||
{
|
||||
Val* id_name = new StringVal(id->Name());
|
||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||
auto id_size = val_mgr->Count(id->ID_Val()->MemoryAllocation());
|
||||
sizes->Assign(id_name, std::move(id_size));
|
||||
Unref(id_name);
|
||||
sizes->Assign(id_name.get(), std::move(id_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1944,7 +1943,7 @@ function global_sizes%(%): var_sizes
|
|||
## .. zeek:see:: global_sizes
|
||||
function global_ids%(%): id_table
|
||||
%{
|
||||
TableVal* ids = new TableVal({NewRef{}, id_table});
|
||||
auto ids = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, id_table});
|
||||
const auto& globals = global_scope()->Vars();
|
||||
|
||||
for ( const auto& global : globals )
|
||||
|
@ -2193,7 +2192,7 @@ function is_v6_subnet%(s: subnet%): bool
|
|||
## Returns: The vector of addresses contained in the routing header data.
|
||||
function routing0_data_to_addrs%(s: string%): addr_vec
|
||||
%{
|
||||
VectorVal* rval = new VectorVal(internal_type("addr_vec")->AsVectorType());
|
||||
auto rval = make_intrusive<VectorVal>(internal_type("addr_vec")->AsVectorType());
|
||||
|
||||
int len = s->Len();
|
||||
const u_char* bytes = s->Bytes();
|
||||
|
@ -2224,7 +2223,7 @@ function routing0_data_to_addrs%(s: string%): addr_vec
|
|||
## .. zeek:see:: counts_to_addr
|
||||
function addr_to_counts%(a: addr%): index_vec
|
||||
%{
|
||||
VectorVal* rval = new VectorVal(internal_type("index_vec")->AsVectorType());
|
||||
auto rval = make_intrusive<VectorVal>(internal_type("index_vec")->AsVectorType());
|
||||
const uint32_t* bytes;
|
||||
int len = a->AsAddr().GetBytes(&bytes);
|
||||
|
||||
|
@ -2445,14 +2444,14 @@ function count_to_port%(num: count, proto: transport_proto%): port
|
|||
function to_addr%(ip: string%): addr
|
||||
%{
|
||||
char* s = ip->AsString()->Render();
|
||||
Val* ret = nullptr;
|
||||
IntrusivePtr<Val> ret;
|
||||
in6_addr tmp;
|
||||
|
||||
if ( IPAddr::ConvertString(s, &tmp) )
|
||||
ret = new AddrVal(IPAddr(tmp));
|
||||
ret = make_intrusive<AddrVal>(IPAddr(tmp));
|
||||
else
|
||||
{
|
||||
ret = new AddrVal(IPAddr());
|
||||
ret = make_intrusive<AddrVal>(IPAddr());
|
||||
builtin_error("failed converting string to IP address", ip);
|
||||
}
|
||||
|
||||
|
@ -2490,7 +2489,7 @@ function to_subnet%(sn: string%): subnet
|
|||
if ( ! IPPrefix::ConvertString(s, &tmp) )
|
||||
builtin_error("failed converting string to IP prefix", sn);
|
||||
|
||||
Val* ret = new SubNetVal(tmp);
|
||||
auto ret = make_intrusive<SubNetVal>(tmp);
|
||||
delete [] s;
|
||||
return ret;
|
||||
%}
|
||||
|
@ -3045,7 +3044,7 @@ char* to_pat_str(int sn, const char* ss)
|
|||
function convert_for_pattern%(s: string%): string
|
||||
%{
|
||||
char* t = to_pat_str(s->Len(), (const char*)(s->Bytes()));
|
||||
StringVal* ret = new StringVal(t);
|
||||
auto ret = make_intrusive<StringVal>(t);
|
||||
delete [] t;
|
||||
return ret;
|
||||
%}
|
||||
|
@ -3390,7 +3389,7 @@ function dump_current_packet%(file_name: string%) : bool
|
|||
function get_current_packet%(%) : pcap_packet
|
||||
%{
|
||||
const Packet* p;
|
||||
RecordVal* pkt = new RecordVal(pcap_packet);
|
||||
auto pkt = make_intrusive<RecordVal>(pcap_packet);
|
||||
|
||||
if ( ! current_pktsrc ||
|
||||
! current_pktsrc->GetCurrentPacket(&p) )
|
||||
|
@ -3976,7 +3975,7 @@ function mmdb_open_asn_db%(f: string%) : bool
|
|||
## .. zeek:see:: lookup_asn
|
||||
function lookup_location%(a: addr%) : geo_location
|
||||
%{
|
||||
RecordVal* location = new RecordVal(geo_location);
|
||||
auto location = make_intrusive<RecordVal>(geo_location);
|
||||
|
||||
#ifdef USE_GEOIP
|
||||
mmdb_check_loc();
|
||||
|
@ -4601,12 +4600,13 @@ function get_file_name%(f: file%): string
|
|||
## .. zeek:see:: rotate_file_by_name calc_next_rotate
|
||||
function rotate_file%(f: file%): rotate_info
|
||||
%{
|
||||
RecordVal* info = f->Rotate();
|
||||
IntrusivePtr<RecordVal> info{AdoptRef{}, f->Rotate()};
|
||||
|
||||
if ( info )
|
||||
return info;
|
||||
|
||||
// Record indicating error.
|
||||
info = new RecordVal(rotate_info);
|
||||
info = make_intrusive<RecordVal>(rotate_info);
|
||||
info->Assign(0, val_mgr->EmptyString());
|
||||
info->Assign(1, val_mgr->EmptyString());
|
||||
info->Assign(2, make_intrusive<Val>(0.0, TYPE_TIME));
|
||||
|
@ -4625,7 +4625,7 @@ function rotate_file%(f: file%): rotate_info
|
|||
## .. zeek:see:: rotate_file calc_next_rotate
|
||||
function rotate_file_by_name%(f: string%): rotate_info
|
||||
%{
|
||||
RecordVal* info = new RecordVal(rotate_info);
|
||||
auto info = make_intrusive<RecordVal>(rotate_info);
|
||||
|
||||
bool is_pkt_dumper = false;
|
||||
bool is_addl_pkt_dumper = false;
|
||||
|
@ -4644,7 +4644,7 @@ function rotate_file_by_name%(f: string%): rotate_info
|
|||
addl_pkt_dumper->Close();
|
||||
}
|
||||
|
||||
FILE* file = rotate_file(f->CheckString(), info);
|
||||
FILE* file = rotate_file(f->CheckString(), info.get());
|
||||
if ( ! file )
|
||||
{
|
||||
// Record indicating error.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue