#if !defined(WELS_COMMON_MEMORY_ALIGN_H__)
#define WELS_COMMON_MEMORY_ALIGN_H__
#include "typedefs.h"
#define MEMORY_MONITOR
#ifdef MEMORY_CHECK
#ifndef MEMORY_MONITOR
#define MEMORY_MONITOR
#endif#endif
#ifdef MEMORY_CHECK
#include <stdio.h>
#endif
namespace WelsCommon {
class CMemoryAlign {
public:
CMemoryAlign (const uint32_t kuiCacheLineSize);
virtual ~CMemoryAlign();
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPointer, const char* kpTag);
const uint32_t WelsGetCacheLineSize() const;
const uint32_t WelsGetMemoryUsage() const;
private:
CMemoryAlign (const CMemoryAlign& kcMa);
CMemoryAlign& operator= (const CMemoryAlign& kcMa);
protected:
uint32_t m_nCacheLineSize;
#ifdef MEMORY_MONITOR
uint32_t m_nMemoryUsageInBytes;
#endif};
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPtr, const char* kpTag);
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }
#define WELS_NEW_OP(object, type) \
(type*)(new object);
#define WELS_DELETE_OP(p) \
if(p) delete p; \
p = NULL;
}
#endif