summaryrefslogtreecommitdiffstats
path: root/src/ikstack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ikstack.c')
-rw-r--r--src/ikstack.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ikstack.c b/src/ikstack.c
index bed4656..0ada246 100644
--- a/src/ikstack.c
+++ b/src/ikstack.c
@@ -7,25 +7,28 @@
#include "common.h"
#include "iksemel.h"
-struct align_test { char a; double b; };
+typedef double align_type ;
+struct align_test { char a; align_type b; };
#define DEFAULT_ALIGNMENT ((size_t) ((char *) &((struct align_test *) 0)->b - (char *) 0))
#define ALIGN_MASK ( DEFAULT_ALIGNMENT - 1 )
#define MIN_CHUNK_SIZE ( DEFAULT_ALIGNMENT * 8 )
#define MIN_ALLOC_SIZE DEFAULT_ALIGNMENT
-#define ALIGN(x) ( (x) + (DEFAULT_ALIGNMENT - ( (x) & ALIGN_MASK)) )
+#define ALIGN(x) ( ((x) + DEFAULT_ALIGNMENT - 1) & ~ALIGN_MASK )
typedef struct ikschunk_struct {
struct ikschunk_struct *next;
size_t size;
size_t used;
size_t last;
- char data[4];
+ align_type align[0] ; // Align data, and ensure struct size matches alignment
+ char data[0];
} ikschunk;
struct ikstack_struct {
size_t allocated;
ikschunk *meta;
ikschunk *data;
+ align_type align[0] ; // Ensure struct size matches alignment
};
static ikschunk *