~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_block.c

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
/*
21
21
  Find record according to record-position.
22
 
      
23
 
  The record is located by factoring position number pos into (p_0, p_1, ...) 
 
22
 
 
23
  The record is located by factoring position number pos into (p_0, p_1, ...)
24
24
  such that
25
25
     pos = SUM_i(block->level_info[i].records_under_level * p_i)
26
26
  {p_0, p_1, ...} serve as indexes to descend the blocks tree.
47
47
    hp_get_new_block()
48
48
      block             HP_BLOCK tree-like block
49
49
      alloc_length OUT  Amount of memory allocated from the heap
50
 
      
51
 
  Interrupts are stopped to allow ha_panic in interrupts 
 
50
 
 
51
  Interrupts are stopped to allow ha_panic in interrupts
52
52
  RETURN
53
53
    0  OK
54
54
    1  Out of memory
65
65
 
66
66
  /*
67
67
    Allocate space for leaf block plus space for upper level blocks up to
68
 
    first level that has a free slot to put the pointer. 
 
68
    first level that has a free slot to put the pointer.
69
69
    In some cases we actually allocate more then we need:
70
70
    Consider e.g. a situation where we have one level 1 block and one level 0
71
 
    block, the level 0 block is full and this function is called. We only 
72
 
    need a leaf block in this case. Nevertheless, we will get here with i=1 
73
 
    and will also allocate sizeof(HP_PTRS) for non-leaf block and will never 
 
71
    block, the level 0 block is full and this function is called. We only
 
72
    need a leaf block in this case. Nevertheless, we will get here with i=1
 
73
    and will also allocate sizeof(HP_PTRS) for non-leaf block and will never
74
74
    use this space.
75
 
    This doesn't add much overhead - with current values of sizeof(HP_PTRS) 
 
75
    This doesn't add much overhead - with current values of sizeof(HP_PTRS)
76
76
    and my_default_record_cache_size we get about 1/128 unused memory.
77
77
   */
78
78
  *alloc_length=sizeof(HP_PTRS)*i+block->records_in_block* block->recbuffer;
102
102
    block->level_info[i].last_blocks->
103
103
      blocks[HP_PTRS_IN_NOD - block->level_info[i].free_ptrs_in_block--]=
104
104
        (unsigned char*) root;
105
 
    
 
105
 
106
106
    /* Add a block subtree with each node having one left-most child */
107
107
    for (j=i-1 ; j >0 ; j--)
108
108
    {
110
110
      block->level_info[j].last_blocks->blocks[0]=(unsigned char*) root;
111
111
      block->level_info[j].free_ptrs_in_block=HP_PTRS_IN_NOD-1;
112
112
    }
113
 
    
114
 
    /* 
 
113
 
 
114
    /*
115
115
      root now points to last (block->records_in_block* block->recbuffer)
116
116
      allocated bytes. Use it as a leaf block.
117
117
    */