KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::FMemory Struct Reference

Class with memory relevant functions. More...

#include <KarmaMemory.h>

Public Types

enum  AllocationHints {
  None = -1 , Default , Temporary , SmallPool ,
  Max
}
 Some allocators can be given hints to treat allocations differently depending on how the memory is used, it's lifetime etc.
 

Static Public Member Functions

static FORCEINLINE void * Memmove (void *Dest, const void *Src, SIZE_T Count)
 Copies count bytes of characters from Src to Dest. If some regions of the source area and the destination overlap, memmove ensures that the original source bytes in the overlapping region are copied before being overwritten.
 
static FORCEINLINE int32_t Memcmp (const void *Buf1, const void *Buf2, SIZE_T Count)
 Compares first Count bytes of memory of Buf1 and Buf2.
 
static FORCEINLINE void * Memset (void *Dest, uint8_t Char, SIZE_T Count)
 Copy value Char in each of first Count characters of object pointed to by Dest.
 
template<class T>
static FORCEINLINE void Memset (T &Src, uint8_t ValueToSet)
 Copy value ValueToSet to template Src.
 
static FORCEINLINE void * Memzero (void *Dest, SIZE_T Count)
 Zeros the Count number of characters of object pointed by Dest.
 
template<class T>
static FORCEINLINE void Memzero (T &Src)
 Zeros the template Src.
 
static FORCEINLINE void * Memcpy (void *Dest, const void *Src, SIZE_T Count)
 Copies Count bytes from the object pointed by Src to the object pointed by Dest.
 
template<class T>
static FORCEINLINE void Memcpy (T &Dest, const T &Src)
 Copies from the object pointed by Src to the object pointed by Dest.
 
static FORCEINLINE void * BigBlockMemcpy (void *Dest, const void *Src, SIZE_T Count)
 Memcpy optimized for big blocks.
 
static FORCEINLINE void * StreamingMemcpy (void *Dest, const void *Src, SIZE_T Count)
 On some platforms memcpy optimized for big blocks that avoid L2 cache pollution are available.
 
static FORCEINLINE void * ParallelMemcpy (void *Dest, const void *Src, SIZE_T Count, EMemcpyCachePolicy Policy=EMemcpyCachePolicy::StoreCached)
 On some platforms memcpy can be distributed over multiple threads for throughput.
 
static FORCEINLINE void Memswap (void *Ptr1, void *Ptr2, SIZE_T Size)
 
static FORCEINLINE void * SystemMalloc (SIZE_T Size)
 C style memory allocation stubs that fall back to C runtime.
 
static FORCEINLINE void SystemFree (void *Ptr)
 C style memory deallocation.
 
static void * Malloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
static FORCEINLINE void * MallocZeroed (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 Return a zeroed block of allocated memory.
 

Detailed Description

Class with memory relevant functions.

Member Function Documentation

◆ BigBlockMemcpy()

static FORCEINLINE void * Karma::FMemory::BigBlockMemcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Memcpy optimized for big blocks.

Parameters
DestObject to copy to
SrcObject to copy from
CountNumber of bytes to be copied
See also
FGenericPlatformMemory::Memcpy
Since
Karma 1.0.0

◆ MallocZeroed()

static FORCEINLINE void * Karma::FMemory::MallocZeroed ( SIZE_T Count,
uint32 Alignment = DEFAULT_ALIGNMENT )
inlinestatic

Return a zeroed block of allocated memory.

Parameters
AlignmentNot functional
CountSize in bytes to be allocated
Todo
Make Alignment functional in Malloc
See also
FMemory::Malloc
Since
Karma 1.0.0

◆ Memcmp()

static FORCEINLINE int32_t Karma::FMemory::Memcmp ( const void * Buf1,
const void * Buf2,
SIZE_T Count )
inlinestatic

Compares first Count bytes of memory of Buf1 and Buf2.

Parameters
Buf1A block of memory
Buf2A block of memory
CountNumber of bytes to be compared
Since
Karma 1.0.0

◆ Memcpy() [1/2]

template<class T>
static FORCEINLINE void Karma::FMemory::Memcpy ( T & Dest,
const T & Src )
inlinestatic

Copies from the object pointed by Src to the object pointed by Dest.

Parameters
SrcObject to copy from
DestObject to copy to
Since
Karma 1.0.0

◆ Memcpy() [2/2]

static FORCEINLINE void * Karma::FMemory::Memcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Copies Count bytes from the object pointed by Src to the object pointed by Dest.

Parameters
SrcObject to copy from
DestObject to copy to
CountNumber of bytes to be copied
Remarks
If both objects overlap, behavior is undefined
Since
Karma 1.0.0

◆ Memmove()

static FORCEINLINE void * Karma::FMemory::Memmove ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Copies count bytes of characters from Src to Dest. If some regions of the source area and the destination overlap, memmove ensures that the original source bytes in the overlapping region are copied before being overwritten.

Remarks
make sure that the destination buffer is the same size or larger than the source buffer!
Parameters
DestWhere to copy bytes to
SrcWhere to copy bytes from
CountSize of bytes to be copied
Since
Karma 1.0.0

◆ Memset() [1/2]

template<class T>
static FORCEINLINE void Karma::FMemory::Memset ( T & Src,
uint8_t ValueToSet )
inlinestatic

Copy value ValueToSet to template Src.

Parameters
SrcCopy the value to
ValueToSetValue to be copied
Since
Karma 1.0.0

◆ Memset() [2/2]

static FORCEINLINE void * Karma::FMemory::Memset ( void * Dest,
uint8_t Char,
SIZE_T Count )
inlinestatic

Copy value Char in each of first Count characters of object pointed to by Dest.

Parameters
DestCopy the value to
CharValue to be copied
CountNumber of characters in the object to be copied to
Since
Karma 1.0.0

◆ Memzero() [1/2]

template<class T>
static FORCEINLINE void Karma::FMemory::Memzero ( T & Src)
inlinestatic

Zeros the template Src.

Parameters
SrcThe reference to the variable to be zeroed
Since
Karma 1.0.0

◆ Memzero() [2/2]

static FORCEINLINE void * Karma::FMemory::Memzero ( void * Dest,
SIZE_T Count )
inlinestatic

Zeros the Count number of characters of object pointed by Dest.

Parameters
DestSet zeros of the object
CountNumber of characters
Since
Karma 1.0.0

◆ ParallelMemcpy()

static FORCEINLINE void * Karma::FMemory::ParallelMemcpy ( void * Dest,
const void * Src,
SIZE_T Count,
EMemcpyCachePolicy Policy = EMemcpyCachePolicy::StoreCached )
inlinestatic

On some platforms memcpy can be distributed over multiple threads for throughput.

Parameters
DestObject to copy to
SrcObject to copy from
PolicyIs copy result immidiately or gaply accessed by CPU
Since
Karma 1.0.0

◆ StreamingMemcpy()

static FORCEINLINE void * Karma::FMemory::StreamingMemcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

On some platforms memcpy optimized for big blocks that avoid L2 cache pollution are available.

Parameters
DestObject to copy to
SrcObject to copy from
CountNumber of bytes to be copied
See also
FGenericPlatformMemory::Memcpy
Since
Karma 1.0.0

◆ SystemFree()

static FORCEINLINE void Karma::FMemory::SystemFree ( void * Ptr)
inlinestatic

C style memory deallocation.

Parameters
PtrPointer to the location to be deallocated
Since
Karma 1.0.0

◆ SystemMalloc()

static FORCEINLINE void * Karma::FMemory::SystemMalloc ( SIZE_T Size)
inlinestatic

C style memory allocation stubs that fall back to C runtime.

Parameters
SizeSize in bytes to be allocated
Since
Karma 1.0.0

The documentation for this struct was generated from the following files: