2020-01-31 04:02:08 +08:00
|
|
|
diff -ru b/c/src/codec.c a/lang/c/src/codec.c
|
|
|
|
--- b/lang/c/src/codec.c 2020-01-23 16:18:15.119970300 +0200
|
|
|
|
+++ a/lang/c/src/codec.c 2020-01-23 19:31:41.679834300 +0200
|
2020-03-19 14:06:04 +08:00
|
|
|
@@ -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
|
2020-01-31 04:02:08 +08:00
|
|
|
@@ -115,14 +118,14 @@
|
2020-03-19 14:06:04 +08:00
|
|
|
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;
|
2020-01-31 04:02:08 +08:00
|
|
|
@@ -133,7 +136,7 @@
|
2020-03-19 14:06:04 +08:00
|
|
|
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;
|
|
|
|
}
|
2020-01-31 04:02:08 +08:00
|
|
|
@@ -152,13 +155,13 @@
|
2020-03-19 14:06:04 +08:00
|
|
|
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");
|