/* * $Id: tmmem.h,v 1.1.1.1 2004/08/25 19:21:33 jan Exp $ * * Copyright (c) 2002 Jan Algermissen * See the file "COPYING" for copying permission. * */ #ifndef MEM_H #define MEM_H #include "tmtk.h" /* for TM_TRACEFUNCTION */ #ifdef __cplusplus extern "C" { #endif /** \defgroup MemoryManagement * \ingroup LibraryCore * * @{ */ typedef struct TMPool *TMPool; TM_API(TMPool) tm_pool_new(const char *name,TMPool parent,...); TM_API(TMPool) tm_pool_new2(const char *name,TMPool parent,int tabsize); TM_API(void) tm_pool_delete(TMPool *pself); /* TM_API(TM) tm_pool_get_tm(TMPool self); */ TM_API(void *) tm_alloc(TMPool pool,long nbytes, const char *file, int line); TM_API(void *) tm_calloc(TMPool pool,long count, long nbytes, const char *file, int line); TM_API(void *) tm_resize(TMPool pool,void *ptr, long nbytes, const char *file, int line); TM_API(void) tm_free(TMPool pool,void *ptr,const char* var, const char *file, int line); #define TM_ALLOC(ABCDE,nbytes) tm_alloc((ABCDE),(nbytes), __FILE__, __LINE__) #define TM_CALLOC(ABCDE,count,nbytes) tm_calloc((ABCDE),(count),(nbytes), __FILE__, __LINE__) #define TM_RESIZE(ABCDE,ptr,nbytes) ((ptr) = tm_resize((ABCDE),(ptr),(nbytes),__FILE__,__LINE__)) #define TM_FREE(ABCDE,ptr) ((void)(tm_free((ABCDE),(ptr),#ptr,__FILE__,__LINE__) , (ptr) = 0)) #define TM_NEW(ABCDE,p) ((p) = TM_ALLOC((ABCDE),(long)sizeof *(p))) /* #define TM_NEW0(ABCDE,p) ((p) = TM_CALLOC((ABCDE),1,(long)sizeof *(p))) */ /** @} */ #ifdef __cplusplus } // extern C #endif #endif