From 9451b75964b302fda61d87664629ac5c9b8e1374 Mon Sep 17 00:00:00 2001 From: Andreas Schik Date: Fri, 8 Jan 2021 12:59:01 +0100 Subject: [PATCH] Fix storage of multi-byte integers on big endian machines. --- src/cwpack_internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cwpack_internals.h b/src/cwpack_internals.h index b03b3f1..6bba04d 100644 --- a/src/cwpack_internals.h +++ b/src/cwpack_internals.h @@ -50,10 +50,10 @@ #ifdef COMPILE_FOR_BIG_ENDIAN -#define cw_store16(x) *(uint16_t*)p = *(uint16_t*)&x; -#define cw_store32(x) *(uint32_t*)p = *(uint32_t*)&x; +#define cw_store16(x) *(uint16_t*)p = (uint16_t)x; +#define cw_store32(x) *(uint32_t*)p = (uint32_t)x; #ifndef FORCE_ALIGNMENT_64BIT -#define cw_store64(x) *(uint64_t*)p = *(uint64_t*)&x; +#define cw_store64(x) *(uint64_t*)p = (uint64_t)x; #else #define cw_store64(x) memcpy(p,&x,8); #endif