# HG changeset patch # User mas01cr # Date 1195055835 0 # Node ID 42585bd0363608b281d47528fe1c2aa7a2aa1342 # Parent a28690f1402157d289131549ed4510869daa151f Don't use mmap() in database creation diff -r a28690f14021 -r 42585bd03636 audioDB.cpp --- a/audioDB.cpp Wed Nov 14 15:55:09 2007 +0000 +++ b/audioDB.cpp Wed Nov 14 15:57:15 2007 +0000 @@ -379,21 +379,10 @@ error("Can't create database file", dbName, "open"); get_lock(dbfid, 1); - // go to the location corresponding to the last byte - if (lseek (dbfid, size - 1, SEEK_SET) == -1) - error("lseek error in db file", "", "lseek"); - - // write a dummy byte at the last location - if (write (dbfid, "", 1) != 1) - error("write error", "", "write"); - // mmap the output file if(verbosity) { cerr << "header size:" << O2_HEADERSIZE << endl; } - if ((db = (char*) mmap(0, size, PROT_READ | PROT_WRITE, - MAP_SHARED, dbfid, 0)) == (caddr_t) -1) - error("mmap error for creating database", "", "mmap"); dbH = new dbTableHeaderT(); assert(dbH); @@ -414,7 +403,16 @@ dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); dbH->dbSize = size; - memcpy (db, dbH, O2_HEADERSIZE); + write(dbfid, dbH, O2_HEADERSIZE); + + // go to the location corresponding to the last byte + if (lseek (dbfid, size - 1, SEEK_SET) == -1) + error("lseek error in db file", "", "lseek"); + + // write a dummy byte at the last location + if (write (dbfid, "", 1) != 1) + error("write error", "", "write"); + if(verbosity) { cerr << COM_CREATE << " " << dbName << endl; }