MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / freeBlockCount

Method freeBlockCount

source/core/StarBTreeDatabase.cpp:233–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233uint32_t BTreeDatabase::freeBlockCount() {
234 ReadLocker readLocker(m_lock);
235 checkIfOpen("freeBlockCount", true);
236
237 // Go through every FreeIndexBlock in the chain and count all of the tracked
238 // free blocks.
239 BlockIndex count = 0;
240 BlockIndex indexBlockIndex = m_headFreeIndexBlock;
241 while (indexBlockIndex != InvalidBlockIndex) {
242 FreeIndexBlock indexBlock = readFreeIndexBlock(indexBlockIndex);
243 count += 1 + indexBlock.freeBlocks.size();
244 indexBlockIndex = indexBlock.nextFreeBlock;
245 }
246
247 count += m_availableBlocks.size();
248
249 // Include untracked blocks at the end of the file in the free count.
250 count += (m_device->size() - m_deviceSize) / m_blockSize;
251
252 return count;
253}
254
255uint32_t BTreeDatabase::indexBlockCount() {
256 ReadLocker readLocker(m_lock);

Callers 2

testBTreeDatabaseFunction · 0.80
TESTFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by 2

testBTreeDatabaseFunction · 0.64
TESTFunction · 0.64