DDraceNetwork Docs
alloc.h File Reference
#include <new>
#include <base/system.h>
Include dependency graph for alloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __has_feature(x)   0
 
#define ASAN_POISON_MEMORY_REGION(addr, size)    ((void)(addr), (void)(size))
 
#define ASAN_UNPOISON_MEMORY_REGION(addr, size)    ((void)(addr), (void)(size))
 
#define MACRO_ALLOC_HEAP()
 
#define MACRO_ALLOC_POOL_ID()
 
#define MACRO_ALLOC_GET_SIZE(POOLTYPE)   (sizeof(POOLTYPE))
 
#define MACRO_ALLOC_POOL_ID_IMPL(POOLTYPE, PoolSize)
 

Macro Definition Documentation

◆ __has_feature

#define __has_feature (   x)    0

◆ ASAN_POISON_MEMORY_REGION

#define ASAN_POISON_MEMORY_REGION (   addr,
  size 
)     ((void)(addr), (void)(size))

◆ ASAN_UNPOISON_MEMORY_REGION

#define ASAN_UNPOISON_MEMORY_REGION (   addr,
  size 
)     ((void)(addr), (void)(size))

◆ MACRO_ALLOC_GET_SIZE

#define MACRO_ALLOC_GET_SIZE (   POOLTYPE)    (sizeof(POOLTYPE))

◆ MACRO_ALLOC_HEAP

#define MACRO_ALLOC_HEAP ( )
Value:
public: \
void *operator new(size_t Size) \
{ \
void *pObj = malloc(Size); \
mem_zero(pObj, Size); \
return pObj; \
} \
void operator delete(void *pPtr) \
{ \
free(pPtr); \
} \
\
private:

◆ MACRO_ALLOC_POOL_ID

#define MACRO_ALLOC_POOL_ID ( )
Value:
public: \
void *operator new(size_t Size, int Id); \
void operator delete(void *pObj, int Id); \
void operator delete(void *pObj); /* NOLINT(misc-new-delete-overloads) */ \
\
private:

◆ MACRO_ALLOC_POOL_ID_IMPL

#define MACRO_ALLOC_POOL_ID_IMPL (   POOLTYPE,
  PoolSize 
)
Value:
static char gs_PoolData##POOLTYPE[PoolSize][MACRO_ALLOC_GET_SIZE(POOLTYPE)] = {{0}}; \
static int gs_PoolUsed##POOLTYPE[PoolSize] = {0}; \
MAYBE_UNUSED static int gs_PoolDummy##POOLTYPE = (ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE, sizeof(gs_PoolData##POOLTYPE)), 0); \
void *POOLTYPE::operator new(size_t Size, int Id) \
{ \
dbg_assert(sizeof(POOLTYPE) >= Size, "size error"); \
dbg_assert(!gs_PoolUsed##POOLTYPE[Id], "already used"); \
ASAN_UNPOISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
gs_PoolUsed##POOLTYPE[Id] = 1; \
mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
return gs_PoolData##POOLTYPE[Id]; \
} \
void POOLTYPE::operator delete(void *pObj, int Id) \
{ \
dbg_assert(gs_PoolUsed##POOLTYPE[Id], "not used"); \
dbg_assert(Id == (POOLTYPE *)pObj - (POOLTYPE *)gs_PoolData##POOLTYPE, "invalid id"); \
gs_PoolUsed##POOLTYPE[Id] = 0; \
mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
} \
void POOLTYPE::operator delete(void *pObj) /* NOLINT(misc-new-delete-overloads) */ \
{ \
int Id = (POOLTYPE *)pObj - (POOLTYPE *)gs_PoolData##POOLTYPE; \
dbg_assert(gs_PoolUsed##POOLTYPE[Id], "not used"); \
gs_PoolUsed##POOLTYPE[Id] = 0; \
mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \
}
#define ASAN_POISON_MEMORY_REGION(addr, size)
Definition: alloc.h:15
#define MACRO_ALLOC_GET_SIZE(POOLTYPE)
Definition: alloc.h:47