# HG changeset patch # User mas01cr # Date 1195144733 0 # Node ID d434e771c7763d884f46981905de6a0674e860fd # Parent 71c24d0df2c451edabd2db988f08784c1362b44f checks for enough free data space don't use dataBuf any more diff -r 71c24d0df2c4 -r d434e771c776 audioDB.cpp --- a/audioDB.cpp Thu Nov 15 16:22:59 2007 +0000 +++ b/audioDB.cpp Thu Nov 15 16:38:53 2007 +0000 @@ -542,6 +542,10 @@ initInputFile(inFile); } +bool audioDB::enough_data_space_free(off_t size) { + return(dbH->timesTableOffset > dbH->dataOffset + dbH->length + size); +} + void audioDB::insert(const char* dbName, const char* inFile) { forWrite = true; initTables(dbName, inFile); @@ -549,10 +553,10 @@ if(!usingTimes && (dbH->flags & O2_FLAG_TIMES)) error("Must use timestamps with timestamped database","use --times"); - // Check that there is room for at least 1 more file - if((char*)timesTable<((char*)dataBuf+dbH->length+statbuf.st_size-sizeof(int))) + if(!enough_data_space_free(statbuf.st_size - sizeof(int))) { error("Insert failed: no more room in database", inFile); - + } + if(!key) key=inFile; // Linear scan of filenames check for pre-existing feature @@ -716,9 +720,9 @@ initInputFile(thisFile); - // Check that there is room for at least 1 more file - if((char*)timesTable<((char*)dataBuf+(dbH->length+statbuf.st_size-sizeof(int)))) + if(!enough_data_space_free(statbuf.st_size - sizeof(int))) { error("batchinsert failed: no more room in database", thisFile); + } // Linear scan of filenames check for pre-existing feature unsigned alreadyInserted=0; diff -r 71c24d0df2c4 -r d434e771c776 audioDB.h --- a/audioDB.h Thu Nov 15 16:22:59 2007 +0000 +++ b/audioDB.h Thu Nov 15 16:38:53 2007 +0000 @@ -199,6 +199,7 @@ void release_lock(int fd); void create(const char* dbName); void drop(); + bool enough_data_space_free(off_t size); void insert(const char* dbName, const char* inFile); void batchinsert(const char* dbName, const char* inFile); void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);