commit 5b81cf3259def9af21bd7f27b91f5e825b3e6d9b
parent f3b7cff635e76f2c8da7bc3a4b788c3b42875761
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Mar 2026 16:57:10 +0100
Update the sln_node_get_child function
Assert that the node is not a leaf.
Diffstat:
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/sln.h b/src/sln.h
@@ -276,7 +276,7 @@ sln_tree_get_desc
(const struct sln_tree* tree,
struct sln_tree_desc* desc);
-SLN_API const struct sln_node*
+SLN_API const struct sln_node* /* NULL <=> No node */
sln_tree_get_root
(const struct sln_tree* tree);
@@ -284,7 +284,7 @@ SLN_API int
sln_node_is_leaf
(const struct sln_node* node);
-/* Return NULL if the node is a leaf */
+/* The node must not be a leaf */
SLN_API const struct sln_node*
sln_node_get_child
(const struct sln_node* node,
diff --git a/src/sln_tree.c b/src/sln_tree.c
@@ -539,6 +539,7 @@ const struct sln_node*
sln_node_get_child(const struct sln_node* node, const unsigned ichild)
{
ASSERT(node && ichild <= 1);
+ ASSERT(!sln_node_is_leaf(node));
return node + node->offset + ichild;
}