Fix memory aligment
[tedtools.git] / sfxstr.c
index 6337f8c..b94f576 100644 (file)
--- a/sfxstr.c
+++ b/sfxstr.c
@@ -29,6 +29,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <stdint.h>
 #include <sys/types.h>
 #include <sys/file.h>
 #include <sys/uio.h>
@@ -46,7 +47,7 @@
 
 #define SFSTREE_VERSION                0x0100
 
-typedef unsigned long Opaque;  /* XXX sizeof(Opaque) == sizeof(void *) */
+typedef uintptr_t Opaque;  /* XXX sizeof(Opaque) == sizeof(void *) */
 
 #define CHECK_MEMORY(tree)     ( ( (tree)->plainmemory ) ? \
        tlog(TL_CRIT|TL_EXIT, "Tree in plain memory - read only access") : (void)0 ) 
@@ -1199,7 +1200,7 @@ SFSInitFromDump(SFSTree *info, void *pointer, u_int64_t size, void **extradata,
                tlog(TL_CRIT|TL_EXIT, "sizeof(Opaque) mismatch");
        if ( dh->headersize != SFSTDHSZ )
                tlog(TL_CRIT|TL_EXIT, "Tree's header size mismatch (should be %d but %d bytes)", SFSTDHSZ, dh->headersize);
-       if ( size && size != dh->totalen + SFSTDHSZ  + dh->extrasize )
+       if ( size && size != dh->totalen + SFSTDHSZ  + MAXALIGN(dh->extrasize) )
                tlog(TL_CRIT|TL_EXIT, "Memory size mismatch (should be %d but %d bytes)", dh->totalen + SFSTDHSZ + dh->extrasize , size);
 
        info->totalen = dh->totalen;