comparison audioDB.cpp @ 188:0caa733d48c5 no-big-mmap

Test against running off the end of the timesTable properly.
author mas01cr
date Fri, 16 Nov 2007 16:39:59 +0000
parents 530154ca4cf5
children 0280c3f57b6f
comparison
equal deleted inserted replaced
187:530154ca4cf5 188:0caa733d48c5
597 unsigned insertoffset = dbH->length;// Store current state 597 unsigned insertoffset = dbH->length;// Store current state
598 598
599 // Check times status and insert times from file 599 // Check times status and insert times from file
600 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); 600 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double));
601 double* timesdata=timesTable+timesoffset; 601 double* timesdata=timesTable+timesoffset;
602 /* FIXME: work out how to check against wandering off the end of the 602
603 times table. 603 if(timesoffset + numVectors > timesTableLength) {
604 604 error("out of space for times", key);
605 assert(timesdata+numVectors<l2normTable); 605 }
606 */ 606
607 insertTimeStamps(numVectors, timesFile, timesdata); 607 insertTimeStamps(numVectors, timesFile, timesdata);
608 608
609 // Increment file count 609 // Increment file count
610 dbH->numFiles++; 610 dbH->numFiles++;
611 611
763 if(!thisTimesFile->is_open()) 763 if(!thisTimesFile->is_open())
764 error("Cannot open timestamp file",thisTimesFileName); 764 error("Cannot open timestamp file",thisTimesFileName);
765 unsigned insertoffset=dbH->length; 765 unsigned insertoffset=dbH->length;
766 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); 766 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double));
767 double* timesdata=timesTable+timesoffset; 767 double* timesdata=timesTable+timesoffset;
768 assert(timesdata+numVectors<l2normTable); 768 if(timesoffset + numVectors > timesTableLength) {
769 error("out of space for times", key);
770 }
769 insertTimeStamps(numVectors,thisTimesFile,timesdata); 771 insertTimeStamps(numVectors,thisTimesFile,timesdata);
770 if(thisTimesFile) 772 if(thisTimesFile)
771 delete thisTimesFile; 773 delete thisTimesFile;
772 } 774 }
773 775