From 111df0fa45729538cc8ec526c71e854d0f15dc2e Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 8 Apr 2019 16:47:21 -0700 Subject: removed LZ4_stream_t alignment test on Visual it fails on x86 32-bit mode : Visual reports an alignment of 8-bytes (even with alignof()) but actually only align LZ4_stream_t on 4 bytes. The alignment check then fails, resulting in missed initialization. --- lib/lz4.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/lz4.c b/lib/lz4.c index a2e58c0..04a30e7 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1284,17 +1284,25 @@ LZ4_stream_t* LZ4_createStream(void) return lz4s; } +#ifndef _MSC_VER /* for some reason, Visual fails the aligment test on 32-bit x86 : + it reports an aligment of 8-bytes, + while actually aligning LZ4_stream_t on 4 bytes. */ static size_t LZ4_stream_t_alignment(void) { struct { char c; LZ4_stream_t t; } t_a; return sizeof(t_a) - sizeof(t_a.t); } +#endif LZ4_stream_t* LZ4_initStream (void* buffer, size_t size) { DEBUGLOG(5, "LZ4_initStream"); if (size < sizeof(LZ4_stream_t)) return NULL; +#ifndef _MSC_VER /* for some reason, Visual fails the aligment test on 32-bit x86 : + it reports an aligment of 8-bytes, + while actually aligning LZ4_stream_t on 4 bytes. */ if (((size_t)buffer) & (LZ4_stream_t_alignment() - 1)) return NULL; /* alignment check */ +#endif MEM_INIT(buffer, 0, sizeof(LZ4_stream_t)); return (LZ4_stream_t*)buffer; } -- cgit v0.12