Skip to content

Commit f4829d1

Browse files
Fix memory leak of it and it2 in void ClientCode()
Adding delete operations at the end of void ClientCode() to free memory allocated by: Iterator<int, Container<int>> *it = cont.CreateIterator(); Iterator<Data, Container<Data>> *it2 = cont2.CreateIterator();
1 parent 561ccc8 commit f4829d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Iterator/Conceptual/main.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ void ClientCode() {
122122
for (it2->First(); !it2->IsDone(); it2->Next()) {
123123
std::cout << it2->Current()->data() << std::endl;
124124
}
125+
delete it;
126+
delete it2;
125127
}
126128

127129
int main() {
128130
ClientCode();
129131
return 0;
130-
}
132+
}

0 commit comments

Comments
 (0)