diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2023-08-05 10:32:03 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2023-08-05 10:32:03 +0000 |
commit | 09f3eb570fe79bfc0c430b6059d7b4acaf371c24 (patch) | |
tree | 82b410cb29a171da1edd9e5e90074bd3064b553e /src/XExtInt.c | |
parent | 3a7503ec7703f10de17c622ea22b7bff736cea74 (diff) |
Fix double alignment on 32bits machines with strict constraints
Diffstat (limited to 'src/XExtInt.c')
-rw-r--r-- | src/XExtInt.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/XExtInt.c b/src/XExtInt.c index 06474b2..a6a5f80 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -1428,16 +1428,18 @@ copyRawEvent(XGenericEventCookie *cookie_in, in = cookie_in->data; bits = count_bits(in->valuators.mask, in->valuators.mask_len); - len = sizeof(XIRawEvent) + in->valuators.mask_len; + len = pad_to_double(sizeof(XIRawEvent)) + + pad_to_double(in->valuators.mask_len); len += bits * sizeof(double) * 2; ptr = cookie_out->data = malloc(len); if (!ptr) return False; - out = next_block(&ptr, sizeof(XIRawEvent)); + out = next_block(&ptr, pad_to_double(sizeof(XIRawEvent))); *out = *in; - out->valuators.mask = next_block(&ptr, out->valuators.mask_len); + out->valuators.mask + = next_block(&ptr, pad_to_double(out->valuators.mask_len)); memcpy(out->valuators.mask, in->valuators.mask, out->valuators.mask_len); out->valuators.values = next_block(&ptr, bits * sizeof(double)); @@ -1954,7 +1956,8 @@ wireToRawEvent(XExtDisplayInfo *info, xXIRawEvent *in, XGenericEventCookie *cook XIRawEvent *out; void *ptr; - len = sizeof(XIRawEvent) + in->valuators_len * 4; + len = pad_to_double(sizeof(XIRawEvent)) + + pad_to_double(in->valuators_len * 4); bits = count_bits((unsigned char*)&in[1], in->valuators_len * 4); len += bits * sizeof(double) * 2; /* raw + normal */ @@ -1962,7 +1965,7 @@ wireToRawEvent(XExtDisplayInfo *info, xXIRawEvent *in, XGenericEventCookie *cook if (!ptr) return 0; - out = next_block(&ptr, sizeof(XIRawEvent)); + out = next_block(&ptr, pad_to_double(sizeof(XIRawEvent))); out->type = in->type; out->serial = cookie->serial; out->display = cookie->display; @@ -1981,7 +1984,8 @@ wireToRawEvent(XExtDisplayInfo *info, xXIRawEvent *in, XGenericEventCookie *cook out->sourceid = 0; out->valuators.mask_len = in->valuators_len * 4; - out->valuators.mask = next_block(&ptr, out->valuators.mask_len); + out->valuators.mask + = next_block(&ptr, pad_to_double(out->valuators.mask_len)); memcpy(out->valuators.mask, &in[1], out->valuators.mask_len); out->valuators.values = next_block(&ptr, bits * sizeof(double)); |