Berserk
Static Public Member Functions | Static Public Attributes | List of all members
Memory Class Referencefinal

System memory wrapper. More...

#include <Memory.hpp>

Static Public Member Functions

static void Copy (void *destination, const void *source, size_t sizeInBytes)
 
static void Set (void *destination, int value, size_t sizeInBytes)
 
static int Compare (const void *a, const void *b, size_t sizeInBytes)
 
static void * Allocate (size_t sizeInBytes)
 
static void * Reallocate (void *memory, size_t sizeInBytes)
 
static void Deallocate (void *memory)
 
static size_t GetAllocateCalls ()
 
static size_t GetDeallocateCalls ()
 
static size_t AlignSize (size_t size, size_t alignment)
 

Static Public Attributes

static const size_t ALIGNMENT = 16
 
static const size_t KiB = 1024
 
static const size_t MiB = 1024 * KiB
 

Detailed Description

System memory wrapper.

Member Function Documentation

◆ AlignSize()

static size_t Memory::AlignSize ( size_t  size,
size_t  alignment 
)
inlinestatic

Align size to specified alignment.

Parameters
sizeSize in bytes to align
alignmentAlignment in bytes (must be power of 2)
Returns
Aligned size

◆ Allocate()

static void* Memory::Allocate ( size_t  sizeInBytes)
inlinestatic

Dynamically allocates data by default system allocator.

Parameters
sizeInBytesNon-zero size in byte to allocate
Returns
Pointer to allocated memory

◆ Compare()

static int Memory::Compare ( const void *  a,
const void *  b,
size_t  sizeInBytes 
)
inlinestatic

Compare two raw buffers

Parameters
aInput buffer
bInput buffer
sizeInBytesRange to compare
Returns
0 if equals

◆ Copy()

static void Memory::Copy ( void *  destination,
const void *  source,
size_t  sizeInBytes 
)
inlinestatic

Copy source to the destination region.

Note
If sizeInBytes == 0 function does nothing.
Parameters
destinationWhere to copy data
sourceData to copy
sizeInBytesSize of the source region to copy (in bytes)

◆ Deallocate()

static void Memory::Deallocate ( void *  memory)
inlinestatic

Deallocates previously allocated memory with Allocate() or Reallocate() functions.

Parameters
memoryPointer to free

◆ GetAllocateCalls()

static size_t Memory::GetAllocateCalls ( )
inlinestatic
Returns
Total number of allocate calls

◆ GetDeallocateCalls()

static size_t Memory::GetDeallocateCalls ( )
inlinestatic
Returns
Total number of deallocate calls

◆ Reallocate()

static void* Memory::Reallocate ( void *  memory,
size_t  sizeInBytes 
)
inlinestatic

Reallocates previously allocated memory with Allocate() or Reallocate() functions.

Parameters
memoryPointer to memory to reallocate
sizeInBytesNon-zero size in byte to reallocate
Returns

◆ Set()

static void Memory::Set ( void *  destination,
int  value,
size_t  sizeInBytes 
)
inlinestatic

Set destination bytes to value.

Note
If sizeInBytes == 0 function does nothing.
Parameters
destinationWhere to set data
valueByte to set
sizeInBytesSize of the destination region to set (in bytes)

Member Data Documentation

◆ ALIGNMENT

const size_t Memory::ALIGNMENT = 16
static

◆ KiB

const size_t Memory::KiB = 1024
static

◆ MiB

const size_t Memory::MiB = 1024 * KiB
static

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