diff options
author | Yann Collet <cyan@fb.com> | 2019-04-08 23:47:21 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2019-04-08 23:47:21 (GMT) |
commit | 111df0fa45729538cc8ec526c71e854d0f15dc2e (patch) | |
tree | 2c74da9d82a13a8b9f73dd1d2bac7a4116549023 | |
parent | da19cc79da6eb7aba915e6deae57ca5c7ac6930f (diff) | |
download | lz4-111df0fa45729538cc8ec526c71e854d0f15dc2e.zip lz4-111df0fa45729538cc8ec526c71e854d0f15dc2e.tar.gz lz4-111df0fa45729538cc8ec526c71e854d0f15dc2e.tar.bz2 |
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.
-rw-r--r-- | lib/lz4.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; } |