Skip to content

Commit

Permalink
Mem leak remove
Browse files Browse the repository at this point in the history
  • Loading branch information
msoos committed Feb 28, 2024
1 parent 257b80c commit 75f5149
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 8 additions & 0 deletions scripts/build_sanitize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

rm -rf cm* CM* lib* Testing* tests* include tests Make* test sbva
CXX=clang++ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTING=ON -DSANITIZE=ON ..
make -j26
make test
15 changes: 7 additions & 8 deletions src/sbva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class Formula {
curr_clause++;
}
}
free(line);
delete cache;
cache = nullptr;

Expand Down Expand Up @@ -474,16 +475,13 @@ class Formula {
// (B v E) (B v F) (B v H)
// (C v E) (C v F) (C v H)
//
vector< tuple<int, int, int> > *matched_entries = new vector< tuple<int, int, int> >();
matched_entries->reserve(10000);
vector< tuple<int, int, int> > matched_entries;

// Keep a list of the literals that are matched so we can sort and count later.
vector<int> matched_entries_lits;
matched_entries_lits.reserve(10000);

// Used for priority queue updates.
unordered_set<int> lits_to_update;
lits_to_update.reserve(10000);

// Track number of replacements (new auxiliary variables).
size_t num_replacements = 0;
Expand Down Expand Up @@ -546,8 +544,8 @@ class Formula {

while (1) {
// P = {}
matched_entries->resize(0);
matched_entries_lits.resize(0);
matched_entries.clear();
matched_entries_lits.clear();

if (config.verbosity) {
cout << "Iteration, Mlit: ";
Expand Down Expand Up @@ -610,7 +608,7 @@ class Formula {
// if lit not in Mlit then
if (!found) {
// Add to clause match matrix.
matched_entries->push_back(make_tuple(lit, other_idx, i));
matched_entries.push_back(make_tuple(lit, other_idx, i));
matched_entries_lits.push_back(lit);
}
}
Expand Down Expand Up @@ -697,7 +695,7 @@ class Formula {
matched_clauses_id_swap.resize(lmax_count);

int insert_idx = 0;
for (auto pair : *matched_entries) {
for (const auto& pair : matched_entries) {
config.steps--;
int lit = get<0>(pair);
if (lit != lmax) continue;
Expand Down Expand Up @@ -950,6 +948,7 @@ using namespace SBVAImpl;
CNF::~CNF() {
Formula* f = (Formula*)data;
delete f;
f = nullptr;
}

void CNF::run(SBVA::Tiebreak t) {
Expand Down

0 comments on commit 75f5149

Please sign in to comment.