5 #ifndef Protium_Chunk_h_
6 #define Protium_Chunk_h_
32 bool Init( std::size_t size,
unsigned char n );
34 void Reset( std::size_t blockSize,
unsigned char blocks );
38 void*
Allocate( std::size_t blocks );
40 void Deallocate(
void * p, std::size_t blocks );
50 bool IsCorrupt(
unsigned char numBlocks, std::size_t blockSize,
bool checkIndexes )
const;
52 bool IsBlockAvailable(
void* p,
unsigned char numBlocks, std::size_t blockSize )
const;
54 inline bool HasBlock(
void* p, std::size_t chunkLength )
const {
55 unsigned char * pc =
static_cast< unsigned char *
>( p );
56 return (
fData <= pc ) && ( pc <
fData + chunkLength );
60 return (
fNAvail == numBlocks );
72 #endif //File Guardian
bool IsFilled(void) const
Checks to see if this is filled.
Pool of allocation chunks.
unsigned char fFirstAvailable
First Available block.
bool IsCorrupt(unsigned char numBlocks, std::size_t blockSize, bool checkIndexes) const
bool HasBlock(void *p, std::size_t chunkLength) const
Checks if this block belongs to this chunk.
bool HasAvailable(unsigned char numBlocks) const
Checks to see if this number of blocks is available in this chunk.
void * Allocate(std::size_t blocks)
Allocates out a number of additional blocks.
void Reset(std::size_t blockSize, unsigned char blocks)
Each time a chunk is reused, it needs to be reset.
Represents a fixed number of blocks.
bool Init(std::size_t size, unsigned char n)
unsigned char fNAvail
Number of available blocks.
void Deallocate(void *p, std::size_t blocks)
DeAllocates a number of blocks starting at pointer.
void Release()
Deallocates all blocks in chunck.
bool IsBlockAvailable(void *p, unsigned char numBlocks, std::size_t blockSize) const
Checks the block starting at p and for p+numBlocks*blockSize checks to see if they're used...