~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_block.cc

  • Committer: Brian Aker
  • Date: 2010-06-22 01:08:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1635.
  • Revision ID: brian@gaz-20100622010850-eh2gi2i0e1kp0jye
Put a copy of the Session in the root of function to make use of.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* functions on blocks; Keys and records are saved in blocks */
17
17
 
30
30
 
31
31
unsigned char *hp_find_block(HP_BLOCK *block, uint32_t pos)
32
32
{
33
 
  int i;
34
 
  HP_PTRS *ptr; /* block base ptr */
 
33
  register int i;
 
34
  register HP_PTRS *ptr; /* block base ptr */
35
35
 
36
 
  for (i= block->levels-1, ptr=block->root ; i > 0 ; i--)
 
36
  for (i=block->levels-1, ptr=block->root ; i > 0 ; i--)
37
37
  {
38
38
    ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level];
39
39
    pos%=block->level_info[i].records_under_level;
58
58
 
59
59
int hp_get_new_block(HP_BLOCK *block, size_t *alloc_length)
60
60
{
61
 
  uint32_t i;
 
61
  register uint32_t i,j;
62
62
  HP_PTRS *root;
63
63
 
64
64
  for (i=0 ; i < block->levels ; i++)
106
106
        (unsigned char*) root;
107
107
 
108
108
    /* Add a block subtree with each node having one left-most child */
109
 
    for (uint32_t j= i-1 ; j >0 ; j--)
 
109
    for (j=i-1 ; j >0 ; j--)
110
110
    {
111
111
      block->level_info[j].last_blocks= root++;
112
112
      block->level_info[j].last_blocks->blocks[0]=(unsigned char*) root;
127
127
 
128
128
unsigned char *hp_free_level(HP_BLOCK *block, uint32_t level, HP_PTRS *pos, unsigned char *last_pos)
129
129
{
130
 
  int max_pos;
 
130
  int i,max_pos;
131
131
  unsigned char *next_ptr;
132
132
 
133
133
  if (level == 1)
134
 
  {
135
134
    next_ptr=(unsigned char*) pos+block->recbuffer;
136
 
  }
137
135
  else
138
136
  {
139
137
    max_pos= (block->level_info[level-1].last_blocks == pos) ?
141
139
    HP_PTRS_IN_NOD;
142
140
 
143
141
    next_ptr=(unsigned char*) (pos+1);
144
 
    for (int i= 0; i < max_pos ; i++)
 
142
    for (i=0 ; i < max_pos ; i++)
145
143
      next_ptr=hp_free_level(block,level-1,
146
144
                              (HP_PTRS*) pos->blocks[i],next_ptr);
147
145
  }
148
 
 
149
146
  if ((unsigned char*) pos != last_pos)
150
147
  {
151
148
    free((unsigned char*) pos);