diff --git a/daemon/bencode.c b/daemon/bencode.c index 0683c213a..fc5638d69 100644 --- a/daemon/bencode.c +++ b/daemon/bencode.c @@ -16,13 +16,11 @@ #define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */ -#define BENCODE_ALLOC_ALIGN 8 - struct __bencode_buffer_piece { char *tail; unsigned int left; struct __bencode_buffer_piece *next; - char buf[0]; + char buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN))); }; struct __bencode_free_list { void *ptr; diff --git a/include/bencode.h b/include/bencode.h index 30f448412..ca8d85f6c 100644 --- a/include/bencode.h +++ b/include/bencode.h @@ -7,6 +7,8 @@ #include "compat.h" +#define BENCODE_ALLOC_ALIGN 8 + struct bencode_buffer; enum bencode_type; struct bencode_item; @@ -35,7 +37,7 @@ struct bencode_item { long long int value; /* when decoding an integer, contains the value; otherwise used internally */ bencode_item_t *parent, *child, *last_child, *sibling; bencode_buffer_t *buffer; - char __buf[0]; + char __buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN))); }; struct bencode_buffer {