#if !defined(__MEMLIB_H__)
#define __MEMLIB_H__

#if defined(USE_STDMEMLIB)

#include <stddef.h>
#include <malloc.h>
#include <string.h>

#define MemoryInit()
#define MemoryDone()

#define MemoryAlloc   malloc
#define MemoryCalloc	calloc
#define MemoryFree(x) { if (*(x)) { free((void*) *(x)); *(x)=NULL; } }
#define MemorySet     memset
#define MemoryMove    memmove
#define MemoryCopy    memcpy
#define MemoryCompare memcmp

#else

#include "deflib.h"

#if defined(__cplusplus)
extern "C" {
#endif

void MemoryInit();
void MemoryDone();

void *MemoryAlloc(size_t size);
void *MemoryCalloc(size_t num,size_t size);
void MemoryFree(void** ptr);
void *MemorySet(void *dest,int c,size_t count);
void *MemoryMove(void *dest,const void *src,size_t count);
void *MemoryCopy(void *dest,const void *src,size_t count);
int MemoryCompare(const void *buf1,const void *buf2, size_t count);

#if defined(__cplusplus)
}
#endif

#endif // USE_STDMEMLIB

#endif // __MEMLIB_H__
