File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -87,16 +87,15 @@ namespace alg {
87
87
void Insert (int32_t k) {
88
88
node r = m_root;
89
89
if (r->n == 2 *T - 1 ) {
90
- node s = (node)allocate_node ();
91
90
// place the old root node to the end of the file
92
91
m_root->flag &= ~ONDISK;
93
92
WRITE (m_root);
94
93
// new root
94
+ node s = (node)allocate_node ();
95
95
s->flag &= ~LEAF;
96
- s->offset = 0 ;
97
- s->n = 0 ;
98
96
s->c [0 ] = m_root->offset ;
99
- // free(m_root);
97
+ // free old & set new
98
+ free (m_root);
100
99
m_root = s;
101
100
split_child (s, 0 );
102
101
insert_nonfull (s, k);
@@ -110,7 +109,7 @@ namespace alg {
110
109
* search a key, returns node and index
111
110
*/
112
111
search_r search (node x, int32_t k) {
113
- uint16_t i = 0 ;
112
+ int32_t i = 0 ;
114
113
search_r ret;
115
114
while (i<x->n && k > x->key [i]) i++;
116
115
@@ -178,7 +177,7 @@ namespace alg {
178
177
z->flag |= (y->flag & LEAF);
179
178
z->n = T - 1 ;
180
179
181
- uint16_t j;
180
+ int32_t j;
182
181
for (j=0 ;j<T-1 ;j++) { // init z
183
182
z->key [j] = y->key [j+T];
184
183
}
@@ -204,7 +203,7 @@ namespace alg {
204
203
x->key [j+1 ] = x->key [j];
205
204
}
206
205
x->key [i] = y->key [T-1 ];
207
- x->n = x->n +1 ;
206
+ x->n = x->n +1 ;
208
207
WRITE (x);
209
208
}
210
209
You can’t perform that action at this time.
0 commit comments