SBSPSS/source/mem/memory.h

78 lines
1.7 KiB
C
Raw Normal View History

2000-08-29 21:54:22 +02:00
/**************************/
/*** Memory Alloc Stuff ***/
/**************************/
#ifndef __MEMORY_HEADER__
#define __MEMORY_HEADER__
#ifndef _GLOBAL_HEADER_
#include "system\global.h"
#endif
2000-11-21 16:34:03 +01:00
/*****************************************************************************/
2001-05-17 18:39:58 +02:00
// Define if you want to debug memory
#ifdef __USER_paul__
#ifdef __VERSION_DEBUG__
#define __DEBUG_MEM__
#endif
2000-11-21 16:21:20 +01:00
#endif
2000-08-29 21:54:22 +02:00
/*****************************************************************************/
2001-05-29 22:31:02 +02:00
#define LListLen (256)
2000-08-29 21:54:22 +02:00
/*****************************************************************************/
typedef struct
{
char *Addr;
u32 Len;
u16 Prev;
u16 Next;
}sLLNode;
typedef struct
{
u32 TotalRam;
u32 RamUsed;
u16 Head;
u16 Tail;
u16 SP;
u16 Stack[LListLen];
sLLNode Nodes[LListLen];
} sLList;
/*****************************************************************************/
char * MemAllocate( u32 Size, char const *Name, char const * File, int LineNumber);
void MemInit();
void MemFree(void *Addr);
void * operator new(size_t Size, const char * name = NULL);
void * operator new[](size_t Size, const char * name = NULL);
void operator delete(void *Ptr);
void operator delete[](void *Ptr);
2001-05-17 18:39:58 +02:00
#ifdef __DEBUG_MEM__
2000-11-21 16:34:03 +01:00
void dumpDebugMem();
2001-05-17 18:39:58 +02:00
void DebugMemFontInit();
2000-11-21 16:34:03 +01:00
#define MemAlloc( Size, Name ) MemAllocate( (Size), (Name), __FILE__, __LINE__ )
2000-08-29 21:54:22 +02:00
#else
2000-11-21 16:34:03 +01:00
#define MemAlloc(Size,Name) MemAllocate( (Size), NULL, NULL, 0 )
2001-05-17 18:39:58 +02:00
#define dumpDebugMem ;
#define DebugMemFontInit ;
2000-08-29 21:54:22 +02:00
#endif
/*****************************************************************************/
extern sLList MainRam; // Ah well!
/*****************************************************************************/
#endif