// // G A M E.O.N.E - LOW LEVEL LIB V1.0 // Copyright (C) 2001 LEVEL ONE ENTERTAINMENT, // Licensed under the terms of LGPL. //:--------------------------------------------------------------------------- //:Description // // GAME.O.N.E - LOWLEVELLIB V1.0 // #ifndef _LLMEM_H #define _LLMEM_H #include "driver/driver.h" #include inline void * llmem_alloc(int size){ return malloc(size); } inline void * llmem_realloc( void * ptr, int newsize ) { return realloc(ptr,newsize); } inline void llmem_free(void * ptr){ free(ptr); } //------------------------------------------------------------------------------- #if 0 /*! * memory functions */ void * llmem_allocX(int size); void * llmem_reallocX( void * ptr, int newsize ); void llmem_freeX(void * ptr); inline void * llmem_alloc( int size ){ void *res = llmem_allocX( size ); DebugOutLn("alloc: %d, ptr=%x",size,res); return res; } inline void llmem_free( void * ptr ){ DebugOutLn("free: ptr=%x",ptr); if(ptr)llmem_freeX( ptr ); } inline void * operator new( unsigned int sz ) { void *res = llmem_allocX( sz ); DebugOutLn("new: %d, ptr=%x",sz,res); return res; } inline void operator delete( void * ptr ) { DebugOutLn("delete: ptr=%x",ptr); if(ptr)llmem_freeX( ptr ); } inline void * llmem_realloc( void * ptr, int size ){ void *res = llmem_reallocX(ptr,size); DebugOutLn("realloc: %d, ptr=%x oldptr=%x",size,res,ptr); return res; } inline llmem_strncpy(char * dst, const char * src, int dstsize ){ while( dstsize -- > 1){ if( *src == 0 ) break; *dst++ = *src++; } *dst = 0; } inline char * llmem_strdup(const char *src){ int l = strlen(src); DebugOutLn("strdup: len=%d, %s",l,src); char * ptr = (char*)llmem_allocX(l+1); memcpy(ptr,src,l); ptr[l]=0; return ptr; } #endif extern int llmem_current_allocated_memory; extern int llmem_maxpeak_allocated_memory; #endif