heap_storage.cpp
SlottedPage* HeapFile::get_new(void) {
    char block[DbBlock::BLOCK_SZ];
    memset(block, 0, sizeof(block));
    Dbt data(block, sizeof(block));

    int block_id = ++this->last;
    Dbt key(&block_id, sizeof(block_id));

    // write out an empty block and read it back in so Berkeley DB is managing the memory
    SlottedPage* page = new SlottedPage(data, this->last, true);
    this->db.put(nullptr, &key, &data, 0); // write it out with initialization applied
    delete page;
    this->db.get(nullptr, &key, &data, 0);
    return new SlottedPage(data, this->last);
}
// Allocate a new block for the database file.
// Returns the new empty DbBlock that is managing the records in this block and its block id.
// Provided by professor Lundeen

Allocate a new block for the database file.
Returns the new empty DbBlock that is managing the records in this block and its block id.
Provided by professor Lundeen
Allocate a new block for the database file . Returns the new empty DbBlock that is managing the records in this block and its block id . Provided by professor Lundeen
SlottedPage* HeapFile::get_new(void) {
    char block[DbBlock::BLOCK_SZ];
    memset(block, 0, sizeof(block));
    Dbt data(block, sizeof(block));
    int block_id = ++this->last;
    Dbt key(&block_id, sizeof(block_id));
    SlottedPage* page = new SlottedPage(data, this->last, true);
    this->db.put(nullptr, &key, &data, 0); 
    delete page;
    this->db.get(nullptr, &key, &data, 0);
    return new SlottedPage(data, this->last);
}
SlottedPage * HeapFile :: get_new ( void ) { char block [ DbBlock :: BLOCK_SZ ] ; memset ( block , 0 , sizeof ( block ) ) ; Dbt data ( block , sizeof ( block ) ) ; int block_id = ++ this -> last ; Dbt key ( & block_id , sizeof ( block_id ) ) ; SlottedPage * page = new SlottedPage ( data , this -> last , true ) ; this -> db . put ( nullptr , & key , & data , 0 ) ; delete page ; this -> db . get ( nullptr , & key , & data , 0 ) ; return new SlottedPage ( data , this -> last ) ; }
Allocate a new block for the database file.
Allocate a new block for the database file .
// write out an empty block and read it back in so Berkeley DB is managing the memory
 // write it out with initialization applied
