gwnavruntime/base/memory.h File Reference

memory.h File Reference

Namespaces

 Kaim
 

Macros

#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
 
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
 

Macro Definition Documentation

#define KY_DEFINE_NEW_DELETE_OPERATORS (   MemStat)
Value:
public: \
KY_MEMORY_REDEFINE_NEW(NavigationClass, MemStat) \
KY_MEMORY_DEFINE_PLACEMENT_NEW \
private:

This macro defines new and delete operators.

For internal use in the declarations of classes that do not derive from NewOverrideBase.

#define KY_REFCOUNT_MALLOC_FREE (   ClassName)
Value:
public: \
KY_INLINE void AddRef() { RefCount ++; } \
KY_INLINE void Release() \
{ \
if ((RefCount.ExchangeAdd_NoSync(-1) - 1) == 0) \
KY_FREE(this); \
} \
int GetRefCount() const { return RefCount; } \
private: \
ClassName(); /* Default constructor implementation mandatory */ \
static KY_INLINE ClassName* Create(char* memoryStart) \
{ \
ClassName* instance = (::new((ClassName*)memoryStart) ClassName()); \
if (instance) instance->RefCount = 1; \
return instance; \
} \
private: \
mutable AtomicInt<int> RefCount;

Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with Kaim::Ptr whose instances are created via placement new in their own preallocated buffer.

Go to the source code of this file.