ADTF
|
Memory block class. More...
Public Types | |
enum | tMemoryLockFlags { ML_CURRENT = 0x01 , ML_FUTURE = 0x02 } |
Memory locking flags enumeration to control memory locking. More... | |
Public Member Functions | |
cMemoryBlock () | |
Default constructor. | |
cMemoryBlock (tSize nSize) | |
Constructor which preallocates memory. More... | |
cMemoryBlock (const cMemoryBlock &oBlock) | |
Copy constructor. More... | |
virtual | ~cMemoryBlock () |
Destructor. | |
tResult | Alloc (tSize nSize) |
(Re)allocates memory More... | |
tResult | Resize (tSize nSize) |
(Re)allocates memory More... | |
tResult | Alloc (tSize nSize, tSize nAlignment, tUInt32 ui32Flags=0) |
Allocates memory at addresses that are a multiple of an alignment value. More... | |
tVoid | Free () |
Frees all allocated memory. | |
tVoid * | GetPtr () const |
Get a pointer to the allocated memory. More... | |
tSize | GetSize () const |
Get the amount of allocated memory in bytes. More... | |
tResult | Set (const tVoid *src, tSize nByteCount) |
Copy data and adjust allocated memory size as necessary. More... | |
tResult | CopyTo (tVoid *dest) const |
Copy data from the allocated memory into the provided destination buffer. More... | |
tResult | Zero () |
Sets all allocated bytes to zero. More... | |
operator tVoid * () const | |
Returns a pointer to the allocated memory or nullptr if no memory has been allocated. More... | |
tResult | Swap (cMemoryBlock &refMemBlock) |
Swaps the administrated memory between two memory blocks. More... | |
Static Public Member Functions | |
static tVoid * | AllocPageAlignedMemory (tSize nSize, tSize nPageSize=0) |
use More... | |
static tVoid | FreePageAlignedMemory (tVoid *pMemory) |
use More... | |
static tVoid | MemCopy (tVoid *pDest, const tVoid *pSrc, tSize nCount) |
Copies data from one buffer to another. More... | |
static tVoid | MemZero (tVoid *pDest, tSize nCount) |
Sets the data of a buffer to zero. More... | |
static tVoid | MemSet (tVoid *pDest, tInt nValue, tSize nCount) |
Fills the data bytes of a buffer to the specified value. More... | |
static tInt | MemCmp (const tVoid *pMem1, const tVoid *pMem2, tSize nCount) |
Compares the data bytes of two memory buffers. More... | |
static tResult | MemLock (const tVoid *pAddress, tSize nSize) |
Locks part of the calling process's virtual address space into RAM preventing that memory from being paged to the swap area,. More... | |
static tResult | MemUnlock (const tVoid *pAddress, tSize nSize) |
Unlocks part of the virtual address previously locked by cMemoryBlock::MemLock. More... | |
static tResult | MemLockAll (tUInt32 nFlags) |
Locks the whole virtual address area. More... | |
static tResult | MemUnlockAll () |
Unlocks all the virtual address areas previously locked by cMemoryBlock::MemLock or cMemoryBlock::MemLockAll . More... | |
Protected Attributes | |
tVoid * | m_Ptr |
Pointer to memory block. | |
tVoid * | m_pBuffer |
Internal buffer. | |
tSize | m_nSize |
Size of buffer. | |
Static Protected Attributes | |
static tUInt32 | m_ui32Protector |
Protector for debugging purposes. | |
static tUInt32 | m_ui32DefaultSectorSize |
Default sector size. | |
Memory block class.
Assists to administrates blocks of memory by allocation, deletion etc.
Definition at line 19 of file memoryblock.h.
enum tMemoryLockFlags |
Memory locking flags enumeration to control memory locking.
Definition at line 27 of file memoryblock.h.
cMemoryBlock | ( | tSize | nSize | ) |
Constructor which preallocates memory.
nSize | [in] The amount of space to allocate. |
cMemoryBlock | ( | const cMemoryBlock & | oBlock | ) |
Copy constructor.
oBlock | [in] Memoryblock to copy. |
(Re)allocates memory
nSize | [in] The amount of space to allocate. |
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::cFileRingBuffer().
Allocates memory at addresses that are a multiple of an alignment value.
nSize | [in] The amount of space to allocate. |
nAlignment | [in] The alignment value, must be a power of two. If this is less then 1, the standard allocation is used |
ui32Flags | [in] Unused. |
use
nSize | use |
nPageSize | use |
Copy data from the allocated memory into the provided destination buffer.
dest | [in] The destination buffer. |
use
pMemory | use |
tVoid* GetPtr | ( | ) | const |
Get a pointer to the allocated memory.
Referenced by cBitSerializer::cBitSerializer(), cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::cFileRingBuffer(), and cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::FillForAlignment().
tSize GetSize | ( | ) | const |
Get the amount of allocated memory in bytes.
Referenced by cBitSerializer::cBitSerializer(), and cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::cFileRingBuffer().
Compares the data bytes of two memory buffers.
pMem1 | [in] The buffer1. |
pMem2 | [in] The buffer2. |
nCount | [in] The amount of bytes that should be compared. |
Referenced by cStringPiece::Compare(), cStringPiece::operator==(), and cStringPiece::StartsWith().
Copies data from one buffer to another.
pDest | [in] The destination buffer. |
pSrc | [in] The source buffer. |
nCount | [in] The amount of bytes that should be copied. |
Referenced by cMemoryPtr::Assign(), ConverterBase< T >::CopyBytesFromBuffer(), cMemoryPtr::CopyTo(), adtf_ddl::access_element::get_array_value(), adtf_ddl::access_element::get_struct_value(), cSystem::cAdapterInfo::HandleAdapterInfo(), ConverterBase< T >::ReadSignal(), adtf_ddl::access_element::set_struct_value(), and ConverterBase< T >::WriteSignal().
Locks part of the calling process's virtual address space into RAM preventing that memory from being paged to the swap area,.
pAddress | [in] Start address of memory to be locked |
nSize | [in] Size of memory area to be locked |
Locks the whole virtual address area.
nFlags | [in] The flags argument is constructed as the bitwise OR of one or more flags of constants defined in enumeration {cMemoryBlock::tMemoryLockFlags}. |
Fills the data bytes of a buffer to the specified value.
pDest | [in] The destination buffer. |
nValue | [in] The value to set. |
nCount | [in] The amount of bytes that should be copied. |
Unlocks part of the virtual address previously locked by cMemoryBlock::MemLock.
pAddress | [in] Start address of memory to be unlocked |
nSize | [in] Size of memory area to be unlocked |
|
static |
Unlocks all the virtual address areas previously locked by cMemoryBlock::MemLock or cMemoryBlock::MemLockAll .
Sets the data of a buffer to zero.
pDest | [in] The destination buffer. |
nCount | [in] The amount of bytes that should be copied. |
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::cFileRingBuffer().
operator tVoid * | ( | ) | const |
Returns a pointer to the allocated memory or nullptr if no memory has been allocated.
(Re)allocates memory
nSize | [in] The amount of space to allocate. |
Copy data and adjust allocated memory size as necessary.
If nByteCount is different to the currently hold amount of memory, the previously allocated memory is free'd and nByteCount of memory is being re-allocated. Any exisiting data is lost.
src | [in] The source data. If this is nullptr, any allocated memory is freed. |
nByteCount | [in] The size of the source data. if this is 0, any allocated memory is freed |
tResult Swap | ( | cMemoryBlock & | refMemBlock | ) |
Swaps the administrated memory between two memory blocks.
refMemBlock | [in] The memory block to switch data with. |
tResult Zero | ( | ) |
Sets all allocated bytes to zero.