Mercurial > hg > audiodb
changeset 211:50da444004fe refactoring
delete_arrays() function.
author | mas01cr |
---|---|
date | Fri, 30 Nov 2007 10:19:26 +0000 |
parents | c9722e12acae |
children | 1292c2e37734 |
files | audioDB.h query.cpp |
diffstat | 2 files changed, 17 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.h Thu Nov 29 10:18:04 2007 +0000 +++ b/audioDB.h Fri Nov 30 10:19:26 2007 +0000 @@ -196,6 +196,7 @@ void sequence_average(double *buffer, int length, int seqlen); void initialize_arrays(int track, unsigned int numVectors, double *query, double *data_buffer, double **D, double **DD); + void delete_arrays(int track, unsigned int numVectors, double **D, double **DD); void read_data(int track, double **data_buffer_p, size_t *data_buffer_size_p); void trackSequenceQueryNN(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0); void trackSequenceQueryRad(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);
--- a/query.cpp Thu Nov 29 10:18:04 2007 +0000 +++ b/query.cpp Fri Nov 30 10:19:26 2007 +0000 @@ -134,6 +134,19 @@ } } +void audioDB::delete_arrays(int track, unsigned int numVectors, double **D, double **DD) { + if(D != NULL) { + for(unsigned int j = 0; j < numVectors; j++) { + delete[] D[j]; + } + } + if(DD != NULL) { + for(unsigned int j = 0; j < numVectors; j++) { + delete[] DD[j]; + } + } +} + void audioDB::read_data(int track, double **data_buffer_p, size_t *data_buffer_size_p) { if (trackTable[track] * sizeof(double) * dbH->dim > *data_buffer_size_p) { if(*data_buffer_p) { @@ -491,18 +504,8 @@ else break; } - } // Duration match - - // Clean up current track - if(D!=NULL){ - for(j=0; j<numVectors; j++) - delete[] D[j]; - } - - if(DD!=NULL){ - for(j=0; j<numVectors; j++) - delete[] DD[j]; - } + } // Duration match + delete_arrays(track, numVectors, D, DD); } // per-track reset array values for(unsigned k=0; k<pointNN; k++){ @@ -891,17 +894,7 @@ break; } } // Duration match - - // Clean up current track - if(D!=NULL){ - for(j=0; j<numVectors; j++) - delete[] D[j]; - } - - if(DD!=NULL){ - for(j=0; j<numVectors; j++) - delete[] DD[j]; - } + delete_arrays(track, numVectors, D, DD); } // per-track reset array values for(unsigned k=0; k<pointNN; k++){