Fix memory leaks - batch 1 (#6411)

This commit is contained in:
Geza Lore
2025-09-09 22:39:44 +01:00
committed by GitHub
parent 83ff8e13ba
commit dd11d5a598
26 changed files with 228 additions and 191 deletions
+3 -3
View File
@@ -1628,16 +1628,16 @@ class RandomizeVisitor final : public VNVisitor {
}
AstNodeStmt* createArrayForeachLoop(FileLine* const fl, AstNodeDType* const dtypep,
AstNodeExpr* exprp, AstVar* const outputVarp) {
V3UniqueNames* uniqueNamep = new V3UniqueNames{"__Vrandarr"};
V3UniqueNames uniqueNames{"__Vrandarr"};
AstNodeDType* tempDTypep = dtypep;
AstVar* randLoopIndxp = nullptr;
AstNodeStmt* stmtsp = nullptr;
auto createLoopIndex = [&](AstNodeDType* tempDTypep) {
if (VN_IS(tempDTypep, AssocArrayDType)) {
return new AstVar{fl, VVarType::VAR, uniqueNamep->get(""),
return new AstVar{fl, VVarType::VAR, uniqueNames.get(""),
VN_AS(tempDTypep, AssocArrayDType)->keyDTypep()};
}
return new AstVar{fl, VVarType::VAR, uniqueNamep->get(""),
return new AstVar{fl, VVarType::VAR, uniqueNames.get(""),
dtypep->findBasicDType(VBasicDTypeKwd::UINT32)};
};
auto createForeachLoop = [&](AstNodeExpr* tempElementp, AstVar* randLoopIndxp) {