Skip to content

Commit

Permalink
Minor fixes in memory management to crack.compiler.Def.
Browse files Browse the repository at this point in the history
  • Loading branch information
mindhog committed Jun 20, 2019
1 parent 3fbff46 commit b9d3ab4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/Def.cc
Expand Up @@ -19,10 +19,14 @@ Def::Def(const std::string &name, VarDef *rep, Def *next) :
next(next) {

rep->incref();
if (next)
next->bind();
}

Def::~Def() {
rep->decref();
if (next)
const_cast<Def*>(next)->release();
}

const char *Def::getName() const {
Expand Down Expand Up @@ -54,10 +58,12 @@ const Def *Def::_getNext(const Def *inst) {
}

void Def::_bind(Def *inst) {
inst->bind();
if (inst)
inst->bind();
}

void Def::_release(Def *inst) {
inst->release();
if (inst)
inst->release();
}

0 comments on commit b9d3ab4

Please sign in to comment.