VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
tklb::memory Namespace Reference

Namespaces

namespace  tracer
 

Classes

class  MemoryPool
 Memory pool interface. More...
 
class  MemoryPoolStack
 Stack based pool. More...
 
class  MemoryPoolStd
 Pool which proxies allocations to the stdlib. More...
 

Functions

static void copy (void *dst, const void *src, const size_t size)
 memcpy wrapper More...
 
static void stringCopy (char *dst, const char *src, size_t size, bool terminate=true)
 
static void set (void *dst, const unsigned char val, size_t size)
 memset wrapper More...
 

Variables

static MemoryPoolDefaultPoolDebug = TKLB_DEFAULT_POOL
 Only for debugging! tklb::memory::DefaultPoolDebug.mPool TODO this is a little whacky and instances are different across compile units. More...
 

Function Documentation

◆ copy()

static void tklb::memory::copy ( void *  dst,
const void *  src,
const size_t  size 
)
inlinestatic

memcpy wrapper

Definition at line 14 of file TMemoryUtil.hpp.

14 {
15 #ifdef TKLB_MEM_NO_STD
16 auto source = reinterpret_cast<const unsigned char*>(src);
17 auto destination = reinterpret_cast<unsigned char*>(dst);
18 for (size_t i = 0; i < size; i++) {
19 destination[i] = source[i];
20 }
21 #else // TKLB_MEM_NO_STD
22 memcpy(dst, src, size);
23 #endif // TKLB_MEM_NO_STD
24 }
Here is the caller graph for this function:

◆ set()

static void tklb::memory::set ( void *  dst,
const unsigned char  val,
size_t  size 
)
inlinestatic

memset wrapper

Definition at line 40 of file TMemoryUtil.hpp.

40 {
41 #ifdef TKLB_MEM_NO_STD
42 auto pointer = reinterpret_cast<unsigned char*>(dst);
43 for (size_t i = 0; i < size; i++) {
44 pointer[i] = val;
45 }
46 #else // TKLB_MEM_NO_STD
47 memset(dst, val, size);
48 #endif // TKLB_MEM_NO_STD
49 }
Here is the caller graph for this function:

◆ stringCopy()

static void tklb::memory::stringCopy ( char *  dst,
const char *  src,
size_t  size,
bool  terminate = true 
)
inlinestatic

Definition at line 26 of file TMemoryUtil.hpp.

26 {
27 for (size_t i = 0; i < size; i++) {
28 dst[i] = src[i];
29 if (src[i] == '\0') { return; }
30 }
31 if (terminate) {
32 // run over the last char to make sure it's terminated
33 dst[size - 1] = '\0';
34 }
35 }
Here is the caller graph for this function:

Variable Documentation

◆ DefaultPoolDebug

MemoryPool& tklb::memory::DefaultPoolDebug = TKLB_DEFAULT_POOL
static

Only for debugging! tklb::memory::DefaultPoolDebug.mPool TODO this is a little whacky and instances are different across compile units.

Definition at line 22 of file TMemory.hpp.