MT#55283 fix bencode buffer alignment

Make sure data is 64-bit aligned. Fixes alignment issues on certain
32-bit archs (armhf).

Change-Id: I66c1fc20e97c62d3d5e266e874812aed74d295ed
mr26.1
Richard Fuchs 3 weeks ago
parent 93c49e9c2e
commit 31375ca349

@ -15,13 +15,11 @@
#define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */
#define BENCODE_ALLOC_ALIGN 8
struct __bencode_buffer_piece {
char *tail;
size_t left;
struct __bencode_buffer_piece *next;
char buf[0];
char buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN)));
};
struct __bencode_hash {
struct bencode_item *buckets[BENCODE_HASH_BUCKETS];

@ -6,6 +6,8 @@
#include "compat.h"
#define BENCODE_ALLOC_ALIGN 8
struct bencode_buffer;
enum bencode_type;
struct bencode_item;
@ -34,7 +36,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 {

Loading…
Cancel
Save