mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
IntrusivePtr: replace the "add_ref" parameter with tag structs
Using a runtime parameter is obscure and error-prone. Avoiding error-prone code and getting reference counting right is the whole point of this class.
This commit is contained in:
parent
7c0863dccf
commit
31b3a56740
7 changed files with 41 additions and 15 deletions
|
@ -1024,7 +1024,7 @@ Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
|||
|
||||
while ( (v = cluster_table->NextEntry(k, c)) )
|
||||
{
|
||||
IntrusivePtr<ListVal> key{cluster_table_val->RecoverIndex(k), false};
|
||||
IntrusivePtr<ListVal> key{AdoptRef{}, cluster_table_val->RecoverIndex(k)};
|
||||
delete k;
|
||||
auto name = key->Index(0)->AsStringVal()->ToStdString();
|
||||
auto rv = v->Value()->AsRecordVal();
|
||||
|
@ -1100,7 +1100,7 @@ std::string Supervisor::NodeConfig::ToJSON() const
|
|||
{
|
||||
auto re = std::make_unique<RE_Matcher>("^_");
|
||||
auto node_val = ToRecord();
|
||||
IntrusivePtr<StringVal> json_val{node_val->ToJSON(false, re.get()), false};
|
||||
IntrusivePtr<StringVal> json_val{AdoptRef{}, node_val->ToJSON(false, re.get())};
|
||||
auto rval = json_val->ToStdString();
|
||||
return rval;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue