Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cHeapBlock Class Reference

#include <cHeap.h>

Inheritance diagram for Gray::cHeapBlock:
Gray::cMemBlock GrayLib::cHashCode GrayLib::cPEM GrayLib::cVariantArrayT GrayLib::cWaveFormat GrayLib::cWaveFormatN

Public Member Functions

 cHeapBlock () noexcept
 
 cHeapBlock (const THIS_t &ref)
 
 cHeapBlock (THIS_t &&ref) noexcept
 
 cHeapBlock (size_t nSize)
 
 cHeapBlock (const void *pDataCopy, size_t nSize)
 
 ~cHeapBlock ()
 
THIS_toperator= (const THIS_t &ref)
 
THIS_toperator= (THIS_t &&ref)
 
bool isValidRead () const noexcept
 
bool isCorrupt () const noexcept
 
size_t get_AllocSize () const
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
void Free ()
 
void FreeSecure ()
 
void SetHeapBlock (void *pData, size_t nSize)
 
void DetachHeapBlock ()
 
bool Alloc (size_t nSize)
 
bool Alloc (const void *pData, size_t nSize)
 
bool ReAlloc (size_t nSize)
 
bool ReAlloc (const void *pData, size_t nSize)
 
bool ReAllocLazy (size_t iSizeNew)
 
bool SetCopy (const cHeapBlock &rSrc)
 
void * get_Data () const noexcept
 
BYTE * get_DataBytes () const noexcept
 
char * get_DataA () const noexcept
 
wchar_t * get_DataW () const noexcept
 
 operator void * () const noexcept
 
 operator BYTE * () const noexcept
 
 operator char * () const noexcept
 
- Public Member Functions inherited from Gray::cMemBlock
 cMemBlock () noexcept
 
 cMemBlock (const void *pData, size_t nSize) noexcept
 
 cMemBlock (const cMemBlock &block) noexcept
 
 cMemBlock (const cMemBlock *pBlock) noexcept
 
size_t get_DataSize () const noexcept
 
void * get_Data () const noexcept
 
BYTE * get_DataBytes () const noexcept
 
char * get_DataA () const noexcept
 
 operator const BYTE * () const noexcept
 
bool isValidPtr () const noexcept
 
bool IsValidIndex (size_t i) const noexcept
 
bool IsValidIndex2 (size_t i) const noexcept
 
bool IsValidPtr (const void *p) const noexcept
 
bool IsValidPtr2 (const void *p) const noexcept
 
bool IsZeros () const noexcept
 
bool IsEqualData (const void *pData, size_t nSize) const noexcept
 
bool IsEqualData (const cMemBlock *pData) const noexcept
 
bool IsEqualData (const cMemBlock &data) const noexcept
 
BYTE * GetOffset (size_t nOffset) const
 
const void * get_DataEnd () const noexcept
 
void put_DataPtr (void *pStart) noexcept
 
void put_Size (size_t nSize) noexcept
 
void SetBlock (void *pData, size_t nSize) noexcept
 
void SetEmptyBlock () noexcept
 
void InitZeros () noexcept
 
StrLen_t ConvertToString (char *pszDst, StrLen_t iDstSizeMax) const
 

Additional Inherited Members

- Static Public Member Functions inherited from Gray::cMemBlock
static COMPARE_t __stdcall Compare (const void *pData1, size_t iLen1, const void *pData2, size_t iLen2)
 
- Protected Attributes inherited from Gray::cMemBlock
size_t m_nSize
 size_t of m_pData in bytes. May be determined at runtime. More...
 
void * m_pData
 

Detailed Description

A cMemBlock allocated using cHeap. Actual heap allocated size might be more than cMemBlock m_nSize in linux or Lazy allocations. destruct = call cHeap::FreePtr().

Constructor & Destructor Documentation

◆ cHeapBlock() [1/5]

Gray::cHeapBlock::cHeapBlock ( )
inlinenoexcept

◆ cHeapBlock() [2/5]

Gray::cHeapBlock::cHeapBlock ( const THIS_t ref)
inline

copy constructor

◆ cHeapBlock() [3/5]

Gray::cHeapBlock::cHeapBlock ( THIS_t &&  ref)
inlinenoexcept

move constructor.

◆ cHeapBlock() [4/5]

Gray::cHeapBlock::cHeapBlock ( size_t  nSize)
inlineexplicit

Construct with initial size. uninitialized data.

◆ cHeapBlock() [5/5]

Gray::cHeapBlock::cHeapBlock ( const void *  pDataCopy,
size_t  nSize 
)
inline

Allocate then Copy pDataCopy data into this.

◆ ~cHeapBlock()

Gray::cHeapBlock::~cHeapBlock ( )
inline

Member Function Documentation

◆ Alloc() [1/2]

bool Gray::cHeapBlock::Alloc ( const void *  pData,
size_t  nSize 
)
inline

Allocate then copy something into it.

◆ Alloc() [2/2]

bool Gray::cHeapBlock::Alloc ( size_t  nSize)
inline

Allocate a memory block of size. assume m_pData points to uninitialized data.

Note
cHeap::AllocPtr(0) != nullptr ! maybe ? Some really old/odd code relies on AllocPtr(0) having/returning a real pointer? not well defined.

◆ DetachHeapBlock()

void Gray::cHeapBlock::DetachHeapBlock ( )
inline

Someone has copied this buffer.

◆ Free()

void Gray::cHeapBlock::Free ( )
inline

◆ FreeSecure()

void Gray::cHeapBlock::FreeSecure ( )
inline

◆ get_AllocSize()

size_t Gray::cHeapBlock::get_AllocSize ( ) const
inline

Special version of get_Size() to measure the true allocation size.

Returns
The actual size of the allocation in bytes. May be greater than I requested? get_Size()
Note
Not always the size of the allocation request in linux or Lazy.

◆ get_Data()

void* Gray::cHeapBlock::get_Data ( ) const
inlinenoexcept

Might be nullptr. that's OK. NOTE: This hides the cMemBlock implimentation so call isCorrupt()

◆ get_DataA()

char* Gray::cHeapBlock::get_DataA ( ) const
inlinenoexcept

Get as a char pointer.

◆ get_DataBytes()

BYTE* Gray::cHeapBlock::get_DataBytes ( ) const
inlinenoexcept

Get as a BYTE pointer. possibly nullptr.

◆ get_DataW()

wchar_t* Gray::cHeapBlock::get_DataW ( ) const
inlinenoexcept

Get as a wchar_t pointer.

◆ GetHeapStats()

size_t Gray::cHeapBlock::GetHeapStats ( OUT ITERATE_t iAllocCount) const
inline

sizeof all children alloc(s). not size of *this

◆ isCorrupt()

bool Gray::cHeapBlock::isCorrupt ( ) const
inlinenoexcept

Is this a corrupt heap pointer? nullptr is OK.

Note
this should only ever be used in debug code. and only in an ASSERT.

◆ isValidRead()

bool Gray::cHeapBlock::isValidRead ( ) const
inlinenoexcept

Is this valid to use for read? Must NOT be nullptr! Has the memory been corrupted ?

Note
this should only ever be used in debug code. and only in an ASSERT.

◆ operator BYTE *()

Gray::cHeapBlock::operator BYTE * ( ) const
inlinenoexcept

◆ operator char *()

Gray::cHeapBlock::operator char * ( ) const
inlinenoexcept

◆ operator void *()

Gray::cHeapBlock::operator void * ( ) const
inlinenoexcept

◆ operator=() [1/2]

THIS_t& Gray::cHeapBlock::operator= ( const THIS_t ref)
inline

copy assignment operator. Allocate a new copy.

◆ operator=() [2/2]

THIS_t& Gray::cHeapBlock::operator= ( THIS_t &&  ref)
inline

move assignment operator

◆ ReAlloc() [1/2]

bool Gray::cHeapBlock::ReAlloc ( const void *  pData,
size_t  nSize 
)
inline

◆ ReAlloc() [2/2]

bool Gray::cHeapBlock::ReAlloc ( size_t  nSize)
inline

If already allocated re-use the current block if possible. copy existing data to new block if move is needed. preserve data.

◆ ReAllocLazy()

bool Gray::cHeapBlock::ReAllocLazy ( size_t  iSizeNew)
inline

Do not shrink the buffer size. only grow. but record the size i asked for. A HeapBlock that is faster to reallocate. optimize reallocate to smaller size by leaving the allocation alone. Lazy realloc in the case of shrink.

◆ SetCopy()

bool Gray::cHeapBlock::SetCopy ( const cHeapBlock rSrc)
inline

Copy from h into me.

◆ SetHeapBlock()

void Gray::cHeapBlock::SetHeapBlock ( void *  pData,
size_t  nSize 
)
inline

Dangerous to allow anyone to poke a new pData pointer and nSize into this. We will free pData on destructor!


The documentation for this class was generated from the following file: