Skip to content

Commit

Permalink
remove codes checking for null pointers and assigning them to null af…
Browse files Browse the repository at this point in the history
…ter released
  • Loading branch information
yushihang committed Mar 18, 2024
1 parent d2483c6 commit 96a8195
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
17 changes: 5 additions & 12 deletions src/calcwit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,13 @@ Circom_CalcWit::Circom_CalcWit (Circom_Circuit *aCircuit, uint maxTh) {

Circom_CalcWit::~Circom_CalcWit() {
// ...
if (inputSignalAssigned != nullptr) {
delete[] inputSignalAssigned;
inputSignalAssigned = nullptr;
}

if (signalValues != nullptr) {
delete[] signalValues;
signalValues = nullptr;
}
delete[] inputSignalAssigned;

delete[] signalValues;

delete[] componentMemory;

if (componentMemory != nullptr) {
delete[] componentMemory;
componentMemory = nullptr;
}
}

uint Circom_CalcWit::getInputSignalHashPosition(u64 h) {
Expand Down
17 changes: 4 additions & 13 deletions src/circom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,20 @@ struct Circom_Circuit {

~Circom_Circuit() {

if (InputHashMap != nullptr) {
delete[] InputHashMap;
InputHashMap = nullptr;
}
delete[] InputHashMap;

if (witness2SignalList != nullptr) {
delete[] witness2SignalList;
witness2SignalList = nullptr;
}
delete[] witness2SignalList;

if (circuitConstants != nullptr) {
delete[] circuitConstants;
circuitConstants = nullptr;
}
delete[] circuitConstants;

for (auto &pair : templateInsId2IOSignalInfo) {
auto *defs = pair.second.defs;
if (defs != nullptr) {
delete[] defs->lengths;
free(defs);
}

}

}
};

Expand Down

0 comments on commit 96a8195

Please sign in to comment.