#ifndef __mem__H
#define __mem__H

#include <stddef.h>
#include "kernel.h"

#ifdef __cplusplus
extern "C" {
#endif

#define EMem_Pack	0x01
#define EMem_Init	0x02
#ifdef MAKEABS
#define EMem_Dump	0x04
#define EMem_Check	0x08
#define EMem_CPP	0x10
#define EMem_InitMask	0x1C

void* __mem_alloc(int, const char*, int);
void* __mem_realloc(void*, int, const char*, int);
void* __mem_calloc(int, int, const char*, int);

#define mem_malloc(x) __mem_alloc(x, __FILE__, __LINE__)
#define mem_realloc(x, y) __mem_realloc(x, y, __FILE__, __LINE__)
#define mem_calloc(x, y) __mem_calloc(x, y, __FILE__, __LINE__)
void mem_free(const void*);
void mem_dump(void);
int  mem_check(void);
void mem_removechecks(void);

#else

void* __mem_alloc(int, const char*, int);
void* __mem_realloc(void*, int, const char*, int);
void* __mem_calloc(int, int, const char*, int);

#define mem_malloc(x) __mem_alloc(x, __FILE__, __LINE__)
#define mem_realloc(x, y) __mem_realloc(x, y, __FILE__, __LINE__)
#define mem_calloc(x, y) __mem_calloc(x, y, __FILE__, __LINE__)
void mem_free(const void*);

#endif

_kernel_oserror* mem_init(int flags);
void mem_finalise(void);
void mem_pack(void);

#ifdef __cplusplus
}
#endif

#endif
