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:
Max Kellermann 2020-02-26 19:12:57 +01:00
parent 7be3641f1d
commit c3ea246237
17 changed files with 885 additions and 1206 deletions

View file

@ -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