| 231 | } |
| 232 | |
| 233 | uint32_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 | |
| 255 | uint32_t BTreeDatabase::indexBlockCount() { |
| 256 | ReadLocker readLocker(m_lock); |