summaryrefslogtreecommitdiff
path: root/mysys/checksum.c
diff options
context:
space:
mode:
Diffstat (limited to 'mysys/checksum.c')
-rw-r--r--mysys/checksum.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/mysys/checksum.c b/mysys/checksum.c
index 1dd135c7ad9..92ec3d550f1 100644
--- a/mysys/checksum.c
+++ b/mysys/checksum.c
@@ -19,19 +19,24 @@
#include "my_sys.h"
/*
- Calculate a long checksum for a memoryblock. Used to verify pack_isam
-
+ Calculate a long checksum for a memoryblock.
+
SYNOPSIS
- checksum()
- mem Pointer to memory block
- count Count of bytes
+ my_checksum()
+ crc start value for crc
+ pos pointer to memory block
+ length length of the block
*/
-ulong checksum(const byte *mem, uint count)
+ha_checksum my_checksum(ha_checksum crc, const byte *pos, uint length)
{
- ulong crc;
- for (crc= 0; count-- ; mem++)
- crc= ((crc << 1) + *((uchar*) mem)) +
- test(crc & ((ulong) 1L << (8*sizeof(ulong)-1)));
+#ifdef NOT_USED
+ const byte *end=pos+length;
+ for ( ; pos != end ; pos++)
+ crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
return crc;
+#else
+ return (ha_checksum)crc32((uint)crc, (const uchar *)pos, length);
+#endif
}
+