commit 968865d1a43c05f9c6722a84c99b9d035c971047
parent c610024b4cddb5d0297e4254dbd701b6f5224d1c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 3 Apr 2026 16:57:33 +0200
Fix the partitioning with the tree's arity > 4
The method for calculating the number of lines per child was incorrect.
It was intended to round up the number of lines per node, thereby
ensuring that the actual number of children calculated from this number
of lines per node not exceed the tree's arity; however, the computation
of this number of lines per child was incorrect whenever the arity was
neither 2 nor 4.
It should be noted that the discovery of this issue is not related to
the actual support for tree arity other than 2. It was discovered during
a code review. The only supported tree arity remains 2.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sln_tree_build.c b/src/sln_tree_build.c
@@ -601,8 +601,8 @@ partition_lines2(struct sln_tree* tree)
/* Compute how the lines of a node are distributed among its children,
* as well as the number of children that node has */
- const size_t nlines_child = (nlines + arity/2/*ceil*/)/arity;
- const size_t nchildren = (nlines + nlines_child/2/*ceil*/)/nlines_child;
+ const size_t nlines_child = (nlines + arity-1/*ceil*/)/arity;
+ const size_t nchildren = (nlines + nlines_child-1/*ceil*/)/nlines_child;
/* Calculate the index of the first child */
size_t ichildren = darray_node_size_get(&tree->nodes);