Fix memory leaks - batch 2 (#6417)

This commit is contained in:
Geza Lore
2025-09-10 22:42:45 +01:00
committed by GitHub
parent 57d8bb5d1f
commit f1396fbced
13 changed files with 188 additions and 156 deletions
+9 -1
View File
@@ -820,6 +820,7 @@ private:
} else {
outconstp->num().setAllBitsX();
}
m_reclaimValuesp.emplace_back(outconstp);
}
outconstp->num().opSelInto(fetchConst(valueFromp)->num(), lsb, selp->widthConst());
assignOutValue(nodep, vscp, outconstp);
@@ -870,6 +871,7 @@ private:
selp->lhsp()->width() + selp->rhsp()->width() + 1,
selp->rhsp()->width());
newValue(selp->lhsp(), outconstp);
VL_DO_DANGLING(outconstp->deleteTree(), outconstp);
}
{
AstConst* const outconstp
@@ -878,6 +880,7 @@ private:
outconstp->num().opSel(fetchConst(valueFromp)->num(),
selp->rhsp()->width() - 1, 0);
newValue(selp->rhsp(), outconstp);
VL_DO_DANGLING(outconstp->deleteTree(), outconstp);
}
}
handleAssignRecurse(nodep, selp->lhsp(), selp->lhsp());
@@ -1449,8 +1452,13 @@ public:
}
~SimulateVisitor() override {
m_constps.clear();
for (AstNode* ip : m_reclaimValuesp) delete ip;
std::vector<AstNode*> unusedRootps;
unusedRootps.reserve(m_reclaimValuesp.size());
for (AstNode* const nodep : m_reclaimValuesp) {
if (!nodep->backp()) unusedRootps.emplace_back(nodep);
}
m_reclaimValuesp.clear();
for (AstNode* const nodep : unusedRootps) VL_DO_DANGLING(nodep->deleteTree(), nodep);
}
};