MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / InitNewBlock

Method InitNewBlock

src/db/blockrecordarray.cpp:95–125  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// InitNewBlock //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

93// InitNewBlock
94///////////////////////////////////////////////////////////////////////////////
95void cBlockRecordArray::InitNewBlock() //throw (eArchive)
96{
97 ASSERT(mpBlockFile != 0);
98 ASSERT((mBlockNum >= 0) && (mBlockNum < mpBlockFile->GetNumBlocks()));
99#ifdef _BLOCKFILE_DEBUG
100 mpBlockFile->AssertValid();
101#endif
102
103 cBlockFile::Block* pBlock = mpBlockFile->GetBlock(mBlockNum);
104 tIndexArray& array = util_GetIndexArray(pBlock);
105 //
106 // set everything to zero..
107 //
108 memset(pBlock->GetData(), 0, cBlockFile::BLOCK_SIZE);
109 pBlock->SetDirty();
110 //
111 // set up the guard byte for the index array...
112 //
113 array.maRecordIndex[0].SetOffset(-1);
114 array.maRecordIndex[0].SetMainIndex(INVALID_INDEX);
115 //
116 // remember that we have been initialized
117 //
118 mbInit = true;
119 //
120 // update the free space and max index variables...
121 //
122 mNumItems = 0;
123 UpdateFreeSpace(pBlock);
124 WriteHeaderInfo(pBlock);
125}
126
127///////////////////////////////////////////////////////////////////////////////
128// InitForExistingBlock

Callers 3

TestBlockRecordArrayFunction · 0.80
OpenImplMethod · 0.80
FindRoomForDataMethod · 0.80

Calls 7

GetNumBlocksMethod · 0.80
SetDirtyMethod · 0.80
SetOffsetMethod · 0.80
SetMainIndexMethod · 0.80
AssertValidMethod · 0.45
GetBlockMethod · 0.45
GetDataMethod · 0.45

Tested by 1

TestBlockRecordArrayFunction · 0.64