~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_block.c

Removed SCCS references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  {p_0, p_1, ...} serve as indexes to descend the blocks tree.
27
27
*/
28
28
 
29
 
unsigned char *hp_find_block(HP_BLOCK *block, uint32_t pos)
 
29
uchar *hp_find_block(HP_BLOCK *block, ulong pos)
30
30
{
31
31
  register int i;
32
32
  register HP_PTRS *ptr; /* block base ptr */
36
36
    ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level];
37
37
    pos%=block->level_info[i].records_under_level;
38
38
  }
39
 
  return (unsigned char*) ptr+ pos*block->recbuffer;
 
39
  return (uchar*) ptr+ pos*block->recbuffer;
40
40
}
41
41
 
42
42
 
56
56
 
57
57
int hp_get_new_block(HP_BLOCK *block, size_t *alloc_length)
58
58
{
59
 
  register uint32_t i,j;
 
59
  register uint i,j;
60
60
  HP_PTRS *root;
61
61
 
62
62
  for (i=0 ; i < block->levels ; i++)
86
86
  }
87
87
  else
88
88
  {
 
89
    dont_break();               /* Dont allow SIGHUP or SIGINT */
89
90
    if ((uint) i == block->levels)
90
91
    {
91
92
      /* Adding a new level on top of the existing ones. */
101
102
    /* Occupy the free slot we've found at level i */
102
103
    block->level_info[i].last_blocks->
103
104
      blocks[HP_PTRS_IN_NOD - block->level_info[i].free_ptrs_in_block--]=
104
 
        (unsigned char*) root;
 
105
        (uchar*) root;
105
106
    
106
107
    /* Add a block subtree with each node having one left-most child */
107
108
    for (j=i-1 ; j >0 ; j--)
108
109
    {
109
110
      block->level_info[j].last_blocks= root++;
110
 
      block->level_info[j].last_blocks->blocks[0]=(unsigned char*) root;
 
111
      block->level_info[j].last_blocks->blocks[0]=(uchar*) root;
111
112
      block->level_info[j].free_ptrs_in_block=HP_PTRS_IN_NOD-1;
112
113
    }
113
114
    
116
117
      allocated bytes. Use it as a leaf block.
117
118
    */
118
119
    block->level_info[0].last_blocks= root;
 
120
    allow_break();              /* Allow SIGHUP & SIGINT */
119
121
  }
120
122
  return 0;
121
123
}
123
125
 
124
126
        /* free all blocks under level */
125
127
 
126
 
unsigned char *hp_free_level(HP_BLOCK *block, uint32_t level, HP_PTRS *pos, unsigned char *last_pos)
 
128
uchar *hp_free_level(HP_BLOCK *block, uint level, HP_PTRS *pos, uchar *last_pos)
127
129
{
128
130
  int i,max_pos;
129
 
  unsigned char *next_ptr;
 
131
  uchar *next_ptr;
130
132
 
131
133
  if (level == 1)
132
 
    next_ptr=(unsigned char*) pos+block->recbuffer;
 
134
    next_ptr=(uchar*) pos+block->recbuffer;
133
135
  else
134
136
  {
135
137
    max_pos= (block->level_info[level-1].last_blocks == pos) ?
136
138
      HP_PTRS_IN_NOD - block->level_info[level-1].free_ptrs_in_block :
137
139
    HP_PTRS_IN_NOD;
138
140
 
139
 
    next_ptr=(unsigned char*) (pos+1);
 
141
    next_ptr=(uchar*) (pos+1);
140
142
    for (i=0 ; i < max_pos ; i++)
141
143
      next_ptr=hp_free_level(block,level-1,
142
144
                              (HP_PTRS*) pos->blocks[i],next_ptr);
143
145
  }
144
 
  if ((unsigned char*) pos != last_pos)
 
146
  if ((uchar*) pos != last_pos)
145
147
  {
146
 
    free((unsigned char*) pos);
 
148
    my_free((uchar*) pos,MYF(0));
147
149
    return last_pos;
148
150
  }
149
151
  return next_ptr;                      /* next memory position */