@@ -68,16 +68,32 @@ struct memoryUsage
static size_t getHeaderPad() {
- size_t pad = sizeof(uintmax_t) - (sizeof(struct chunkHeader) % sizeof(uintmax_t));
- if (pad == sizeof(uintmax_t))
+ size_t alignwith, pad;
+
+ if (sizeof(TYPE_OF_WORD) > sizeof(void*))
+ alignwith = sizeof(TYPE_OF_WORD);
+ else
+ alignwith = sizeof(void*);
+
+ pad = alignwith - (sizeof(struct chunkHeader) % alignwith);
+
+ if (pad == alignwith)
return 0;
else
return pad;
}
static size_t getTrailerPad(size_t length) {
- size_t pad = sizeof(uintmax_t) - (length % sizeof(uintmax_t));
- if (pad == sizeof(uintmax_t))
+ size_t alignwith, pad;
+
+ if (sizeof(TYPE_OF_WORD) > sizeof(void*))
+ alignwith = sizeof(TYPE_OF_WORD);
+ else
+ alignwith = sizeof(void*);
+
+ pad = alignwith - (length % alignwith);
+
+ if (pad == alignwith)
return 0;
else
return pad;
@@ -31,6 +31,8 @@
#include <stdint.h>
#include <stdio.h>
+#define TYPE_OF_WORD uintmax_t /* you should choose something big, if you don't want to waste cpu */
+
#include "list-batman.h"
#include "bitarray.h"
#include "hash.h"
@@ -21,10 +21,8 @@
-#define TYPE_OF_WORD unsigned long /* you should choose something big, if you don't want to waste cpu */
-#define WORD_BIT_SIZE ( sizeof(TYPE_OF_WORD) * 8 )
#include "batman.h"
-
+#define WORD_BIT_SIZE ( sizeof(TYPE_OF_WORD) * 8 )
void bit_init( TYPE_OF_WORD *seq_bits );
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> --- batman/allocate.c | 24 ++++++++++++++++++++---- batman/batman.h | 2 ++ batman/bitarray.h | 4 +--- 3 files changed, 23 insertions(+), 7 deletions(-)