diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2016-12-15 14:39:33 +1300 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2017-02-09 03:17:15 +0100 |
commit | 8bdec7034e121592fa9faec70bd951319334e560 (patch) | |
tree | 34f0a4206a0b39d9ca3e0dc3a1483cf4c349b691 | |
parent | 3c9483f7f9f4b7b98418df76ccb5000a132a7003 (diff) | |
download | samba-8bdec7034e121592fa9faec70bd951319334e560.tar.gz |
binsearch: clarify variable name in greater-than-or-equal search
The exact match variable was called "result" following the other
macros, which confused me for a moment.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | lib/util/binsearch.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/util/binsearch.h b/lib/util/binsearch.h index 001f2c51cd6..454e5ce4742 100644 --- a/lib/util/binsearch.h +++ b/lib/util/binsearch.h @@ -86,31 +86,31 @@ like BINARY_ARRAY_SEARCH_V, but if an exact result is not found, the 'next' argument will point to the element after the place where the exact result would have been. If an exact result is found, 'next' will be NULL. If the - target is beyond the end of the list, both 'result' and 'next' will be NULL. + target is beyond the end of the list, both 'exact' and 'next' will be NULL. Unlike other binsearch macros, where there are several elements that compare - the same, the result will always point to the first one. + the same, the exact result will always point to the first one. If you don't care to distinguish between the 'greater than' and 'equals' - cases, you can use the same pointer for both 'result' and 'next'. + cases, you can use the same pointer for both 'exact' and 'next'. As with all the binsearch macros, the comparison function is always called with the search term first. */ #define BINARY_ARRAY_SEARCH_GTE(array, array_size, target, comparison_fn, \ - result, next) do { \ + exact, next) do { \ int32_t _b, _e; \ - (result) = NULL; (next) = NULL; \ + (exact) = NULL; (next) = NULL; \ if ((array_size) > 0) { \ for (_b = 0, _e = (array_size)-1; _b <= _e; ) { \ int32_t _i = (_b + _e) / 2; \ int _r = comparison_fn(target, array[_i]); \ if (_r == 0) { \ - (result) = &array[_i]; \ + (exact) = &array[_i]; \ _e = _i - 1; \ } else if (_r < 0) { _e = _i - 1; \ } else { _b = _i + 1; } \ } \ - if ((result) == NULL &&_b < (array_size)) { \ + if ((exact) == NULL &&_b < (array_size)) { \ (next) = &array[_b]; \ } } } while (0) |