~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_bitmap.cc

Merge of Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    Create a mask with the upper 'unused' bits set and the lower 'used'
30
30
    bits clear. The bits within each byte is stored in big-endian order.
31
31
   */
32
 
  unsigned char const mask= (~((1 << used) - 1)) & 255;
 
32
  unsigned char const mask= static_cast<unsigned char const>((~((1 << used) - 1)) & 255); 
33
33
 
34
34
  /*
35
35
    The first bytes are to be set to zero since they represent real  bits
87
87
bool MyBitmap::testAndSet(const uint32_t bitPos)
88
88
{
89
89
  unsigned char *value= ((unsigned char*) bitmap) + (bitPos / 8);
90
 
  unsigned char bit= 1 << ((bitPos) & 7);
91
 
  unsigned char res= (*value) & bit;
92
 
  *value|= bit;
 
90
  unsigned char bit= static_cast<unsigned char>(1 << ((bitPos) & 7));
 
91
  unsigned char res= static_cast<unsigned char>((*value) & bit);
 
92
  *value= static_cast<unsigned char>(*value | bit);
93
93
  return res;
94
94
}
95
95
 
98
98
bool MyBitmap::testAndClear(const uint32_t bitPos)
99
99
{
100
100
  unsigned char *byte= (unsigned char*) bitmap + (bitPos / 8);
101
 
  unsigned char bit= 1 << ((bitPos) & 7);
102
 
  unsigned char res= (*byte) & bit;
103
 
  *byte&= ~bit;
 
101
  unsigned char bit= static_cast<unsigned char>(1 << ((bitPos) & 7));
 
102
  unsigned char res= static_cast<unsigned char>((*byte) & bit);
 
103
  *byte= static_cast<unsigned char>(*byte & ~bit);
104
104
  return res;
105
105
}
106
106
 
133
133
  m+= prefix_bytes;
134
134
  if ((prefix_bits= prefix_size & 7))
135
135
  {
136
 
    *m++= (1 << prefix_bits)-1;
 
136
    *m++= static_cast<unsigned char>((1 << prefix_bits)-1);
137
137
  }
138
138
  if ((d= numOfBytesInMap() - prefix_bytes))
139
139
  {
284
284
 
285
285
void MyBitmap::setAbove(const uint32_t from_byte, const uint32_t use_bit)
286
286
{
287
 
  unsigned char use_byte= use_bit ? 0xff : 0;
 
287
  unsigned char use_byte= static_cast<unsigned char>(use_bit ? 0xff : 0);
288
288
  unsigned char *to= (unsigned char *) bitmap + from_byte;
289
289
  unsigned char *end= (unsigned char *) bitmap + (n_bits+7)/8;
290
290