Skip to content

Commit

Permalink
Fix memory leaks in the code (#2753)
Browse files Browse the repository at this point in the history
* Add list recursive freeing

* Add separate chaining free logic

* Add freeing logic to sets

* Fix double free error

* Remove warning raising code
  • Loading branch information
advikkabra authored Jul 16, 2024
1 parent 759df0e commit f4c4b94
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2208,13 +2208,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}

void visit_ListClear(const ASR::ListClear_t& x) {
ASR::List_t* asr_list = ASR::down_cast<ASR::List_t>(ASRUtils::expr_type(x.m_a));
int64_t ptr_loads_copy = ptr_loads;
ptr_loads = 0;
this->visit_expr(*x.m_a);
llvm::Value* plist = tmp;
ptr_loads = ptr_loads_copy;

list_api->list_clear(plist);
list_api->list_clear(plist, asr_list->m_type, module.get());
}

void visit_ListRepeat(const ASR::ListRepeat_t& x) {
Expand Down
Loading

0 comments on commit f4c4b94

Please sign in to comment.