This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new bb31f10 [avro-c] Fixed building with Snappy enabled in Windows
bb31f10 is described below
commit bb31f109c34212e4077518d95671429587bec2db
Author: Michael Spector <[email protected]>
AuthorDate: Fri Jan 24 19:24:46 2020 +0200
[avro-c] Fixed building with Snappy enabled in Windows
---
lang/c/src/codec.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lang/c/src/codec.c b/lang/c/src/codec.c
index 5b55b35..613a914 100644
--- a/lang/c/src/codec.c
+++ b/lang/c/src/codec.c
@@ -24,6 +24,9 @@
# elif defined(__FreeBSD__)
# include <sys/endian.h>
# define __bswap_32 bswap32
+# elif defined(_WIN32)
+# include <stdlib.h>
+# define __bswap_32 _byteswap_ulong
# else
# include <byteswap.h>
# endif
@@ -118,14 +121,14 @@ static int encode_snappy(avro_codec_t c, void * data,
int64_t len)
return 1;
}
- if (snappy_compress(data, len, c->block_data, &outlen) != SNAPPY_OK)
+ if (snappy_compress((const char *)data, len, (char*)c->block_data,
&outlen) != SNAPPY_OK)
{
avro_set_error("Error compressing block with Snappy");
return 1;
}
- crc = __bswap_32(crc32(0, data, len));
- memcpy(c->block_data+outlen, &crc, 4);
+ crc = __bswap_32(crc32(0, (const Bytef *)data, len));
+ memcpy((char*)c->block_data+outlen, &crc, 4);
c->used_size = outlen+4;
return 0;
@@ -136,7 +139,7 @@ static int decode_snappy(avro_codec_t c, void * data,
int64_t len)
uint32_t crc;
size_t outlen;
- if (snappy_uncompressed_length(data, len-4, &outlen) != SNAPPY_OK) {
+ if (snappy_uncompressed_length((const char*)data, len-4, &outlen) !=
SNAPPY_OK) {
avro_set_error("Uncompressed length error in snappy");
return 1;
}
@@ -155,13 +158,13 @@ static int decode_snappy(avro_codec_t c, void * data,
int64_t len)
return 1;
}
- if (snappy_uncompress(data, len-4, c->block_data, &outlen) !=
SNAPPY_OK)
+ if (snappy_uncompress((const char*)data, len-4, (char*)c->block_data,
&outlen) != SNAPPY_OK)
{
avro_set_error("Error uncompressing block with Snappy");
return 1;
}
- crc = __bswap_32(crc32(0, c->block_data, outlen));
+ crc = __bswap_32(crc32(0, (const Bytef *)c->block_data, outlen));
if (memcmp(&crc, (char*)data+len-4, 4))
{
avro_set_error("CRC32 check failure uncompressing block with
Snappy");