# HG changeset patch # User mas01cr # Date 1211214312 0 # Node ID 34ce7f7a177d0f33adee9c5cbeb2c6d7c364301b # Parent 8b7b1734716ce11bb26790670237e64361661289 Remove, I think, memory leaks from audioDB::batchinsert(). Add paired delete / delete[]s, with the catch that we need to handle the key file a bit carefully. diff -r 8b7b1734716c -r 34ce7f7a177d insert.cpp --- a/insert.cpp Mon May 19 16:05:39 2008 +0000 +++ b/insert.cpp Mon May 19 16:25:12 2008 +0000 @@ -203,25 +203,31 @@ error("Must use power with power-enabled database", dbName); unsigned totalVectors=0; - char *thisKey = new char[MAXSTR]; char *thisFile = new char[MAXSTR]; + char *thisKey = 0; + if (key && (key != inFile)) { + thisKey = new char[MAXSTR]; + } char *thisTimesFileName = new char[MAXSTR]; char *thisPowerFileName = new char[MAXSTR]; do{ filesIn->getline(thisFile,MAXSTR); - if(key && key!=inFile) + if(key && key!=inFile) { keysIn->getline(thisKey,MAXSTR); - else + } else { thisKey = thisFile; - if(usingTimes) - timesFile->getline(thisTimesFileName,MAXSTR); - if(usingPower) + } + if(usingTimes) { + timesFile->getline(thisTimesFileName,MAXSTR); + } + if(usingPower) { powerFile->getline(thisPowerFileName, MAXSTR); + } - if(filesIn->eof()) + if(filesIn->eof()) { break; - + } initInputFile(thisFile); if(!enough_per_file_space_free()) { @@ -316,7 +322,17 @@ } while(!filesIn->eof()); VERB_LOG(0, "%s %s %u vectors %ju bytes.\n", COM_BATCHINSERT, dbName, totalVectors, (intmax_t) (totalVectors * dbH->dim * sizeof(double))); + + delete [] thisPowerFileName; + if(key && (key != inFile)) { + delete [] thisKey; + } + delete [] thisFile; + delete [] thisTimesFileName; + delete filesIn; + delete keysIn; + // Report status status(dbName); }