talloc: add TC_ALIGN16() macro
authorStefan Metzmacher <metze@samba.org>
Thu, 31 Mar 2011 14:55:00 +0000 (16:55 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 8 Apr 2011 07:28:10 +0000 (09:28 +0200)
metze

Signed-off-By: Andrew Tridgell <tridge@samba.org>
lib/talloc/talloc.c

index 1c5f76922ad6499b4bf653f7e5527c6aaf66082b..867705fdf458cdd40b833cd759fe712624e059ff 100644 (file)
@@ -147,7 +147,8 @@ struct talloc_chunk {
 };
 
 /* 16 byte alignment seems to keep everyone happy */
-#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15)
+#define TC_ALIGN16(s) (((s)+15)&~15)
+#define TC_HDR_SIZE TC_ALIGN16(sizeof(struct talloc_chunk))
 #define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))
 
 _PUBLIC_ int talloc_version_major(void)
@@ -370,7 +371,7 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
        /*
         * Align size to 16 bytes
         */
-       chunk_size = ((size + 15) & ~15);
+       chunk_size = TC_ALIGN16(size);
 
        if (space_left < chunk_size) {
                return NULL;