~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_checksum.cc

  • Committer: Andrew Hutchings
  • Date: 2011-03-29 20:45:43 UTC
  • mfrom: (2257 drizzle)
  • mto: (2257.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2258.
  • Revision ID: andrew@linuxjedi.co.uk-20110329204543-ssex0nuo8knncgwx
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* Calculate a checksum for a row */
17
17
 
18
18
#include "myisam_priv.h"
 
19
#include <zlib.h>
19
20
 
20
21
using namespace drizzled;
21
22
 
22
 
internal::ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf)
 
23
/*
 
24
  Calculate a long checksum for a memoryblock.
 
25
 
 
26
  SYNOPSIS
 
27
    my_checksum()
 
28
      crc       start value for crc
 
29
      pos       pointer to memory block
 
30
      length    length of the block
 
31
*/
 
32
 
 
33
static ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length)
 
34
{
 
35
  return ha_checksum(crc32((uint32_t)crc, pos, uInt(length)));
 
36
}
 
37
 
 
38
ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf)
23
39
{
24
40
  uint32_t i;
25
 
  internal::ha_checksum crc=0;
 
41
  ha_checksum crc=0;
26
42
  MI_COLUMNDEF *rec=info->s->rec;
27
43
 
28
44
  for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length)
53
69
      pos=buf;
54
70
      break;
55
71
    }
56
 
    crc=internal::my_checksum(crc, pos ? pos : (unsigned char*) "", length);
 
72
    crc=my_checksum(crc, pos ? pos : (unsigned char*) "", length);
57
73
  }
58
74
  return crc;
59
75
}
60
76
 
61
77
 
62
 
internal::ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos)
 
78
ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos)
63
79
{
64
 
  return internal::my_checksum(0, pos, info->s->base.reclength);
 
80
  return my_checksum(0, pos, info->s->base.reclength);
65
81
}