Allocates and frees fixed-size disk blocks.
More...
#include <block_allocator.h>
|
| std::unique_ptr< Impl > | impl_ |
Allocates and frees fixed-size disk blocks.
Tracks free/used state for each block and provides O(n) first-fit allocation suitable for educational simulation.
Definition at line 16 of file block_allocator.h.
◆ BlockAllocator() [1/3]
| contur::BlockAllocator::BlockAllocator |
( |
std::size_t | totalBlocks | ) |
|
|
explicit |
Creates a block allocator over a fixed number of blocks.
- Parameters
-
◆ ~BlockAllocator()
| contur::BlockAllocator::~BlockAllocator |
( |
| ) |
|
◆ BlockAllocator() [2/3]
| contur::BlockAllocator::BlockAllocator |
( |
const BlockAllocator & | | ) |
|
|
delete |
◆ BlockAllocator() [3/3]
| contur::BlockAllocator::BlockAllocator |
( |
BlockAllocator && | | ) |
|
|
noexcept |
◆ allocate()
| Result< std::size_t > contur::BlockAllocator::allocate |
( |
| ) |
|
|
nodiscard |
Allocates one free block.
- Returns
- Block index on success; OutOfMemory if no free blocks remain.
◆ free()
| Result< void > contur::BlockAllocator::free |
( |
std::size_t | blockIndex | ) |
|
|
nodiscard |
Frees a previously allocated block.
- Parameters
-
| blockIndex | Index of block to free. |
- Returns
- Ok on success; InvalidAddress or InvalidState on misuse.
◆ freeBlocks()
| std::size_t contur::BlockAllocator::freeBlocks |
( |
| ) |
const |
|
nodiscardnoexcept |
Number of currently free blocks.
- Returns
- Free block count.
◆ isFree()
| bool contur::BlockAllocator::isFree |
( |
std::size_t | blockIndex | ) |
const |
|
nodiscardnoexcept |
Returns whether block is free.
- Parameters
-
| blockIndex | Block index to query. |
- Returns
- True when free; false for used or out-of-range indices.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ reset()
| void contur::BlockAllocator::reset |
( |
| ) |
|
Resets allocator state, marking every block as free.
◆ totalBlocks()
| std::size_t contur::BlockAllocator::totalBlocks |
( |
| ) |
const |
|
nodiscardnoexcept |
Total number of blocks managed by allocator.
- Returns
- Total block capacity.
◆ impl_
| std::unique_ptr<Impl> contur::BlockAllocator::impl_ |
|
private |
The documentation for this class was generated from the following file: