libr3 is a high-performance path dispatching library. It compiles your route paths into a prefix tree (trie). By using the constructed prefix trie in the start-up time, you may dispatch your routes with efficiency
When r3_node_find_common_prefix() searches for the common prefix it selects the first matched edge, which might not be the best match.
This PR makes sure the longest matching prefix is selected, and includes a testcase for reproducing the issue on baseline.
This makes sure the following paths can be inserted without problems:
The issue also triggered memoryleaks in the legacy testcase check_tree::test_insert_pathl().
This was seen by building using: CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..
These leaks are now gone aswell, see:
check_tree::test_insert_pathl()
..
ret = r3_tree_insert_path(n, "/foo/{id}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idy}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idh}", NULL); <-- leaks (..and the path was not added)
When
r3_node_find_common_prefix()
searches for the common prefix it selects the first matched edge, which might not be the best match.This PR makes sure the longest matching prefix is selected, and includes a testcase for reproducing the issue on baseline. This makes sure the following paths can be inserted without problems:
The issue also triggered memoryleaks in the legacy testcase
check_tree::test_insert_pathl()
. This was seen by building using:CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..
These leaks are now gone aswell, see: