XCSP3-CPP-Parser icon indicating copy to clipboard operation
XCSP3-CPP-Parser copied to clipboard

Deallocation commented

Open massimomorara opened this issue 4 years ago • 0 comments

Playing with valgrind, I've found that, in class XMLParser, there are pointers to allocated memory: in toFree, in toFreeEntity, in allDomains and in variablesList.

Seems that the memory managed is never deallocated but I found a method, XMLParser::InstanceTagAction::endTag() (src/XMLParserTags.cc), where this deallocation is present but commented

void XMLParser::InstanceTagAction::endTag() {
    this->parser->manager->endInstance();
    /*for(XEntity *xe : this->parser->toFree)
        delete xe;
    for(XIntegerEntity *xe : this->parser->toFreeEntity)
        delete xe;
    this->parser->toFree.clear();
    for(XDomainInteger *xdomain :this->parser->allDomains) {
        delete xdomain;
    }
    for(std::map<string, XEntity *>::iterator it = this->parser->variablesList.begin(); it != this->parser->variablesList.end(); ++it) {
        delete it->second;
    }*/
}

Was in the wrong place? Maybe should be in the XMLParser destructor?

Anyway, this memory should be deallocated.

massimomorara avatar Apr 16 '20 17:04 massimomorara