~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_checksum.c

Cleanup around SAFEMALLOC

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Calculate a checksum for a row */
17
17
 
18
 
#include "myisam_priv.h"
19
 
 
20
 
using namespace drizzled;
21
 
 
22
 
internal::ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf)
 
18
#include "myisamdef.h"
 
19
 
 
20
ha_checksum mi_checksum(MI_INFO *info, const uchar *buf)
23
21
{
24
 
  uint32_t i;
25
 
  internal::ha_checksum crc=0;
 
22
  uint i;
 
23
  ha_checksum crc=0;
26
24
  MI_COLUMNDEF *rec=info->s->rec;
27
25
 
28
26
  for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length)
29
27
  {
30
 
    const unsigned char *pos;
 
28
    const uchar *pos;
31
29
    ulong length;
32
30
    switch (rec->type) {
33
31
    case FIELD_BLOB:
40
38
    }
41
39
    case FIELD_VARCHAR:
42
40
    {
43
 
      uint32_t pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1);
 
41
      uint pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1);
44
42
      if (pack_length == 1)
45
 
        length= (ulong) *(unsigned char*) buf;
 
43
        length= (ulong) *(uchar*) buf;
46
44
      else
47
45
        length= uint2korr(buf);
48
46
      pos= buf+pack_length;
53
51
      pos=buf;
54
52
      break;
55
53
    }
56
 
    crc=internal::my_checksum(crc, pos ? pos : (unsigned char*) "", length);
 
54
    crc=my_checksum(crc, pos ? pos : (uchar*) "", length);
57
55
  }
58
56
  return crc;
59
57
}
60
58
 
61
59
 
62
 
internal::ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos)
 
60
ha_checksum mi_static_checksum(MI_INFO *info, const uchar *pos)
63
61
{
64
 
  return internal::my_checksum(0, pos, info->s->base.reclength);
 
62
  return my_checksum(0, pos, info->s->base.reclength);
65
63
}