X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readdistcommand.cpp;h=8de0c34ee039e3c79d539fb7ed531fb2351f3400;hb=edec660ee2be477ac1539109d949a60cb7e16243;hp=6d38f4e4d55cde380570dd53aaa847f96600550f;hpb=cd10743907df223b7dd5b3a3deb20fde758b8ed7;p=mothur.git diff --git a/readdistcommand.cpp b/readdistcommand.cpp index 6d38f4e..8de0c34 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -8,6 +8,9 @@ */ #include "readdistcommand.h" +#include "readphylip.h" +#include "readcolumn.h" +#include "readmatrix.hpp" ReadDistCommand::ReadDistCommand(){ try { @@ -21,7 +24,7 @@ ReadDistCommand::ReadDistCommand(){ else if (format == "matrix") { groupMap = new GroupMap(globaldata->getGroupFile()); groupMap->readMap(); - if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; } + //if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; } globaldata->gGroupmap = groupMap; } @@ -70,10 +73,15 @@ int ReadDistCommand::execute(){ ifstream in; openInputFile(filename, in); matrix = new FullMatrix(in); //reads the matrix file + //memory leak prevention + //if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix; } globaldata->gMatrix = matrix; //save matrix for coverage commands }else { read->read(nameMap); + //to prevent memory leak + if (globaldata->gListVector != NULL) { delete globaldata->gListVector; } globaldata->gListVector = read->getListVector(); + if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix; } globaldata->gSparseMatrix = read->getMatrix(); } return 0;