mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Expr: use class IntrusivePtr
As a side effect, this fixes lots of memory leaks in `*Expr::InitVal()` because in most implementations, the `aggr` parameter leaks.
This commit is contained in:
parent
7be3641f1d
commit
c3ea246237
17 changed files with 885 additions and 1206 deletions
13
src/ID.cc
13
src/ID.cc
|
@ -278,15 +278,14 @@ void ID::SetOption()
|
|||
|
||||
void ID::EvalFunc(Expr* ef, Expr* ev)
|
||||
{
|
||||
Expr* arg1 = new ConstExpr(val->Ref());
|
||||
ListExpr* args = new ListExpr();
|
||||
args->Append(arg1);
|
||||
args->Append(ev->Ref());
|
||||
auto arg1 = make_intrusive<ConstExpr>(IntrusivePtr{NewRef{}, val});
|
||||
auto args = make_intrusive<ListExpr>();
|
||||
args->Append(std::move(arg1));
|
||||
args->Append({NewRef{}, ev});
|
||||
|
||||
CallExpr* ce = new CallExpr(ef->Ref(), args);
|
||||
auto ce = make_intrusive<CallExpr>(IntrusivePtr{NewRef{}, ef}, std::move(args));
|
||||
|
||||
SetVal(ce->Eval(0));
|
||||
Unref(ce);
|
||||
SetVal(ce->Eval(0).release());
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue