commit 7af1f2441dd98c4bb4cb2e622ba8607071f05dcc parent 3b50956e9089d3671aaffdaa19ecb9b6a99208d8 Author: Vincent Forest <vincent.forest@meso-star.com> Date: Tue, 26 Apr 2022 11:04:18 +0200 Fix the tree building Diffstat:
| M | src/sln_tree_build.c | | | 9 | +++++---- |
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/sln_tree_build.c b/src/sln_tree_build.c @@ -57,11 +57,12 @@ tree_build /* Make a leaf */ if(nlines <= args->max_nlines_per_leaf) { NODE(inode)->offset = -1; - inode = istack ? stack[--istack] : SIZE_MAX; + inode = istack ? stack[--istack] : SIZE_MAX; /* Pop the next node */ /* Split the node */ } else { - const size_t split = (nlines + 1/*ceil*/)/2; /* Median split */ + /* Median split */ + const size_t split = NODE(inode)->range[0] + (nlines + 1/*ceil*/)/2; /* Compute the index toward the 2 children (first is the left child, * followed by the righ child) */ @@ -82,10 +83,10 @@ tree_build NODE(ichildren+0)->range[1] = split-1; /* Setup the right child */ NODE(ichildren+1)->range[0] = split; - NODE(ichildren+1)->range[1] = NODE(inode)->range[1];; + NODE(ichildren+1)->range[1] = NODE(inode)->range[1]; inode = ichildren + 0; /* Make the left child current node */ - stack[istack] = ichildren + 1; /* Push the right child */ + stack[istack++] = ichildren + 1; /* Push the right child */ } } #undef NODE