X-Git-Url: http://www.sigaev.ru/git/gitweb.cgi?a=blobdiff_plain;f=tmalloc.h;h=67069ebf0ebcc9ad7936fde1dc518c80ccccf46e;hb=9ebec3abbb483692bfa747d874533e5e2080235b;hp=fce5dbaadfbf209271e21d715f08e56dae179f4d;hpb=ba7e1d079124ac7e5685a0cf918229d1a9a26735;p=tedtools.git diff --git a/tmalloc.h b/tmalloc.h index fce5dba..67069eb 100644 --- a/tmalloc.h +++ b/tmalloc.h @@ -31,6 +31,7 @@ #define __TMALLOC_H__ #include +#include "tools.h" void * tmalloc(size_t size); void * trealloc(void * ptr, size_t size); @@ -54,7 +55,7 @@ typedef struct MemoryChunk { char data[1]; } MemoryChunk; -#define MEMCHNKHDRSZ ( sizeof(u_int32_t)*2 + sizeof(MemoryChunk*) ) +#define MEMCHNKHDRSZ offsetof(MemoryChunk, data) typedef struct MemoryContext { u_int32_t flags; @@ -74,11 +75,6 @@ typedef struct { #define MCASHDRSZ ( sizeof(size_t) + sizeof(MemoryContext*) ) #define MCMAGICKNUMBER (0xFE0FBEEF) -#define TYPEALIGN(ALIGNVAL,LEN) \ - (((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1))) - -#define PTRALIGN(LEN) TYPEALIGN(sizeof(void*), (LEN)) - MemoryContext *allocMemoryContext(MemoryContext* parent, int flags); void freeMemoryContext(MemoryContext* cntx); void* mcalloc(MemoryContext *cntx, size_t size);