util/rb-tree: Return the actual first node from rb_tree_search
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 23 Aug 2023 19:08:21 +0000 (12:08 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 24 Aug 2023 17:50:28 +0000 (17:50 +0000)
commit2ff38260b9a794a84b059cb355f5ffb255739f8e
tree559f6b8c6886a0584a35bb07b134e811e4824a98
parente51056f9f7d210e8730dac143a4aba53df33fd8c
util/rb-tree: Return the actual first node from rb_tree_search

Previously rb_tree_search would return the first node encountered, but
that may not be the first node that would be encoutnered by, say,
rb_tree_foreach.

Two test cases are added.

v2: Add more curly braces. Suggested by Faith.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24856>
src/util/rb_tree.h
src/util/tests/rb_tree_test.cpp