Eliminate warinig.
[tedtools.git] / tmalloc.h
index fce5dba..67069eb 100644 (file)
--- a/tmalloc.h
+++ b/tmalloc.h
@@ -31,6 +31,7 @@
 #define __TMALLOC_H__
 
 #include <sys/types.h>
+#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);