# HG changeset patch # User Mike Becker # Date 1744486351 -7200 # Node ID 5492e8ef05f4c742b35204bbb52181d5e1a6c10e # Parent 7acbaa74fbd00fb4a55bc2f7570eeb82f036d7fa fixes that cx_tree_search() did not investigate subtrees with equally good distance fixes #632 diff -r 7acbaa74fbd0 -r 5492e8ef05f4 CHANGELOG --- a/CHANGELOG Fri Apr 11 16:48:58 2025 +0200 +++ b/CHANGELOG Sat Apr 12 21:32:31 2025 +0200 @@ -5,6 +5,7 @@ * changes grow strategy for the mempory pool to reduce reallocations * fixes implementation of cxBufferTerminate() * fixes allocator arguments for some printf.h functions not being const + * fixes that cx_tree_search() did not investigate subtrees with equally good distance Version 3.1 - 2025-02-11 ------------------------ diff -r 7acbaa74fbd0 -r 5492e8ef05f4 docs/Writerside/topics/about.md --- a/docs/Writerside/topics/about.md Fri Apr 11 16:48:58 2025 +0200 +++ b/docs/Writerside/topics/about.md Sat Apr 12 21:32:31 2025 +0200 @@ -31,7 +31,8 @@ * adds cxMempoolTransfer() and cxMempoolTransferObject() * changes grow strategy for the mempory pool to reduce reallocations * fixes implementation of cxBufferTerminate() -* fixes allocator arguments for some printf.h functions not being const +* fixes allocator arguments for some printf.h functions not being const +* fixes that cx_tree_search() did not investigate subtrees with equally good distance ### Version 3.1 - 2025-02-11 {collapsible="true"} diff -r 7acbaa74fbd0 -r 5492e8ef05f4 src/tree.c --- a/src/tree.c Fri Apr 11 16:48:58 2025 +0200 +++ b/src/tree.c Sat Apr 12 21:32:31 2025 +0200 @@ -226,14 +226,14 @@ int ret_elem = sfunc(elem, node); if (ret_elem == 0) { // if found, exit the search - *result = (void *) elem; + *result = elem; ret = 0; break; } else if (ret_elem > 0 && ret_elem < ret) { // new distance is better *result = elem; ret = ret_elem; - } else { + } else if (ret_elem < 0 || ret_elem > ret) { // not contained or distance is worse, skip entire subtree cxTreeIteratorContinue(iter); }