Store::Block Store::Segment::get(uint32_t block_id, size_t block_size) const { MT_REQUIRE_LT(block_id, getNumBlocks(block_size)); Block block; block.data = memory_.data() + block_id * block_size; block.size = block_size; return block; }
char* Store::getAddressOf(uint32_t id) const { MT_REQUIRE_LT(id, getNumBlocksUnlocked()); const auto num_blocks_mapped = mapped_.getNumBlocks(getBlockSize()); if (id < num_blocks_mapped) { const auto offset = getBlockSize() * id; return static_cast<char*>(mapped_.data) + offset; } else { const auto offset = getBlockSize() * (id - num_blocks_mapped); return buffer_.data.get() + offset; } }