aboutsummaryrefslogtreecommitdiff
path: root/ports/avro-c/snappy-pr-793.patch
blob: 28909318dad9e29dfc66791fc98a748e2197ea94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
@@ -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
@@ -115,14 +118,14 @@
 		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;
@@ -133,7 +136,7 @@
         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;
         }
@@ -152,13 +155,13 @@
 		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");