#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_Log        0x20
#define EMem_InitMask   0x3C

void mem_dump(void);
int  mem_check(void);
void mem_removechecks(void);

#else
#define EMem_InitMask   0x03
#endif

extern const char nil;

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

void __mem_free(const char* f, int l, const void*);

#define _ogg_malloc(x) __mem_alloc(__FILE__, __LINE__, x)
#define _ogg_realloc(x, y) __mem_realloc(__FILE__, __LINE__, x, y)
#define _ogg_calloc(x, y) __mem_calloc(__FILE__, __LINE__, x, y)
#define _ogg_free(x) __mem_free(__FILE__, __LINE__, x)

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

#ifdef __cplusplus
}
#endif

#endif
