DB openDatabase(char *name) {
DB db = new(DBdescriptor);
db->dbname = strdup(name);
db->fd = open(name,O_RDWR);
db->map = readSpaceTable(db);
db->names = readNameTable(db);
return db;
}
void closeDatabase(DB db) {
writeSpaceTable(db,db->map);
writeNameTable(db,db->names);
fsync(db->fd);
close(db->fd);
free(db);
}
|