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>
if ((array_size) > 0) { \
for (_b = 0, _e = (array_size)-1; _b <= _e; ) { \
int32_t _i = (_b + _e) / 2; \
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; \
if (_r == 0) { \
(exact) = &array[_i]; \
_e = _i - 1; \
+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};
static bool test_binsearch_v(struct torture_context *tctx)
{
int array[] = { -11, -7, 0, 1, 723, 1000000};
i, target);
BINARY_ARRAY_SEARCH_GTE(array, a_len, target,
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 */
if (result == NULL) {
/* we think there is no exact match */
i, target);
BINARY_ARRAY_SEARCH_GTE(array, a_len, target,
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 */
if (result == NULL) {
/* we think the target is greater than all elements */
/* vlv_value_compare() is used in a binary search */
static int vlv_value_compare(struct vlv_sort_context *target,
/* vlv_value_compare() is used in a binary search */
static int vlv_value_compare(struct vlv_sort_context *target,
{
struct ldb_result *result = NULL;
struct ldb_message_element *el = NULL;
{
struct ldb_result *result = NULL;
struct ldb_message_element *el = 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;
if (ret != LDB_SUCCESS) {
target->status = ret;
/* The same as vlv_value_compare() but sorting in the opposite direction. */
static int vlv_value_compare_rev(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,
{
return -vlv_value_compare(target, guid);
}
{
return -vlv_value_compare(target, guid);
}