diff options
Diffstat (limited to 'isam')
-rw-r--r-- | isam/isamchk.c | 2 | ||||
-rw-r--r-- | isam/isamdef.h | 1 | ||||
-rw-r--r-- | isam/open.c | 19 | ||||
-rw-r--r-- | isam/pack_isam.c | 2 |
4 files changed, 22 insertions, 2 deletions
diff --git a/isam/isamchk.c b/isam/isamchk.c index dc772290e13..939a4be732f 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -1328,7 +1328,7 @@ int extend; print_error("Found wrong record at %lu",(ulong) start_recpos); got_error=1; } - crc^=checksum(record,info->s->base.reclength); + crc^=_nisam_checksum(record,info->s->base.reclength); link_used+=info->s->pack.ref_length; used+=block_info.rec_len+info->s->pack.ref_length; } diff --git a/isam/isamdef.h b/isam/isamdef.h index 0884b18e997..54656b6842e 100644 --- a/isam/isamdef.h +++ b/isam/isamdef.h @@ -358,6 +358,7 @@ extern int _nisam_read_pack_record(N_INFO *info,ulong filepos,byte *buf); extern int _nisam_read_rnd_pack_record(N_INFO*, byte *,ulong, int); extern int _nisam_pack_rec_unpack(N_INFO *info,byte *to,byte *from, uint reclength); +extern ulong _nisam_checksum(const byte *mem, uint count); typedef struct st_sortinfo { uint key_length; diff --git a/isam/open.c b/isam/open.c index 48fab27cac1..824fbe804ee 100644 --- a/isam/open.c +++ b/isam/open.c @@ -453,3 +453,22 @@ static void setup_key_functions(register N_KEYDEF *keyinfo) } return; } + +/* + Calculate a long checksum for a memoryblock. Used to verify pack_isam + + SYNOPSIS + checksum() + mem Pointer to memory block + count Count of bytes +*/ + +ulong _nisam_checksum(const byte *mem, uint count) +{ + ulong crc; + for (crc= 0; count-- ; mem++) + crc= ((crc << 1) + *((uchar*) mem)) + + test(crc & ((ulong) 1L << (8*sizeof(ulong)-1))); + return crc; +} + diff --git a/isam/pack_isam.c b/isam/pack_isam.c index fd12aac1e09..9108070f918 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -738,7 +738,7 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) { if (! error) { - crc^=checksum(record,reclength); + crc^=_nisam_checksum(record,reclength); for (pos=record,count=huff_counts ; count < end_count ; count++, |