GTree: Annotate the real return value type of g_tree_nnodes ()

g_tree_nnodes () is returning a signed integer type (gint), however the
tree node counter value type is really an unsigned integer (guint).

This means that the returned size will be negative if the container holds
more than G_MAXINT elements.

Add a note to this function that its return value can be cast back to
guint in order to support its full range of values.

This will also make sure that we take this into account in future Glib
versions.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
This commit is contained in:
Maciej S. Szmigiero 2023-08-08 14:52:05 +02:00
parent 76f7961a7b
commit 1237525da2

View File

@ -1454,6 +1454,11 @@ g_tree_height (GTree *tree)
* Gets the number of nodes in a #GTree. * Gets the number of nodes in a #GTree.
* *
* Returns: the number of nodes in @tree * Returns: the number of nodes in @tree
*
* The node counter value type is really a #guint,
* but it is returned as a #gint due to backward
* compatibility issues (can be cast back to #guint to
* support its full range of values).
*/ */
gint gint
g_tree_nnodes (GTree *tree) g_tree_nnodes (GTree *tree)