xcsp3team / XCSP3-CPP-Parser

XCSP3 Core Parser in C++
MIT License
19 stars 11 forks source link

Deallocation commented #24

Open massimomorara opened 4 years ago

massimomorara commented 4 years ago

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.