summaryrefslogtreecommitdiffhomepage
path: root/src/crc.c
diff options
context:
space:
mode:
authorYukihiro Matz Matsumoto <[email protected]>2013-03-27 00:52:24 +0900
committerYukihiro Matz Matsumoto <[email protected]>2013-03-27 00:52:24 +0900
commita0f6e4d58edc296b0a3f8a3f7be5ab62ff61604d (patch)
tree5c2c21a850129b3d596034d81bcdf063613305a4 /src/crc.c
parent1abe678e1c0a5fd153c07d71634f262fd51b7668 (diff)
parent974febd315a6520184f95cb50a7c2b46e4582002 (diff)
downloadmruby-a0f6e4d58edc296b0a3f8a3f7be5ab62ff61604d.tar.gz
mruby-a0f6e4d58edc296b0a3f8a3f7be5ab62ff61604d.zip
resolve conflict from #964
Diffstat (limited to 'src/crc.c')
-rw-r--r--src/crc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/crc.c b/src/crc.c
index a54909fdb..463c7abe6 100644
--- a/src/crc.c
+++ b/src/crc.c
@@ -6,6 +6,8 @@
#include <limits.h>
#include <stdint.h>
+#include <sys/types.h>
+
// Calculate CRC (CRC-16-CCITT)
//
// 0000_0000_0000_0000_0000_0000_0000_0000
@@ -16,10 +18,11 @@
#define CRC_CARRY_BIT (0x01000000)
uint16_t
-calc_crc_16_ccitt(unsigned char *src, int nbytes)
+calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc)
{
- uint32_t crcwk = 0ul;
- int ibyte, ibit;
+ size_t ibyte;
+ uint32_t ibit;
+ uint32_t crcwk = crc << 8;
for (ibyte = 0; ibyte < nbytes; ibyte++) {
crcwk |= *src++;
@@ -32,3 +35,4 @@ calc_crc_16_ccitt(unsigned char *src, int nbytes)
}
return (uint16_t)(crcwk >> 8);
}
+