mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
binsearch: make BINARY_ARRAY_SEARCH_GTE compare against a pointer
This is in preparation for improvements in our handling of linked attributes where we make changes to the pointer in the process of comparing it (for caching purposes). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
8bdec7034e
commit
83c4ad778e
@ -103,7 +103,7 @@
|
||||
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]); \
|
||||
int _r = comparison_fn(target, &array[_i]); \
|
||||
if (_r == 0) { \
|
||||
(exact) = &array[_i]; \
|
||||
_e = _i - 1; \
|
||||
|
@ -31,6 +31,11 @@ static int int_cmp(int a, int b)
|
||||
return a - b;
|
||||
}
|
||||
|
||||
static int int_cmp_p(int a, int *b)
|
||||
{
|
||||
return a - *b;
|
||||
}
|
||||
|
||||
static bool test_binsearch_v(struct torture_context *tctx)
|
||||
{
|
||||
int array[] = { -11, -7, 0, 1, 723, 1000000};
|
||||
@ -72,7 +77,7 @@ static bool test_binsearch_gte(struct torture_context *tctx)
|
||||
i, target);
|
||||
|
||||
BINARY_ARRAY_SEARCH_GTE(array, a_len, target,
|
||||
int_cmp, result, next);
|
||||
int_cmp_p, result, next);
|
||||
|
||||
if (result == NULL) {
|
||||
/* we think there is no exact match */
|
||||
@ -134,7 +139,7 @@ static bool test_binsearch_gte(struct torture_context *tctx)
|
||||
i, target);
|
||||
|
||||
BINARY_ARRAY_SEARCH_GTE(array, a_len, target,
|
||||
int_cmp, result, result);
|
||||
int_cmp_p, result, result);
|
||||
|
||||
if (result == NULL) {
|
||||
/* we think the target is greater than all elements */
|
||||
|
@ -232,7 +232,7 @@ static int send_referrals(struct results_store *store,
|
||||
/* vlv_value_compare() is used in a binary search */
|
||||
|
||||
static int vlv_value_compare(struct vlv_sort_context *target,
|
||||
struct GUID guid)
|
||||
struct GUID *guid)
|
||||
{
|
||||
struct ldb_result *result = NULL;
|
||||
struct ldb_message_element *el = NULL;
|
||||
@ -243,7 +243,7 @@ static int vlv_value_compare(struct vlv_sort_context *target,
|
||||
NULL
|
||||
};
|
||||
|
||||
ret = vlv_search_by_dn_guid(ac->module, ac, &result, &guid, attrs);
|
||||
ret = vlv_search_by_dn_guid(ac->module, ac, &result, guid, attrs);
|
||||
|
||||
if (ret != LDB_SUCCESS) {
|
||||
target->status = ret;
|
||||
@ -259,7 +259,7 @@ static int vlv_value_compare(struct vlv_sort_context *target,
|
||||
|
||||
/* The same as vlv_value_compare() but sorting in the opposite direction. */
|
||||
static int vlv_value_compare_rev(struct vlv_sort_context *target,
|
||||
struct GUID guid)
|
||||
struct GUID *guid)
|
||||
{
|
||||
return -vlv_value_compare(target, guid);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user