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; \
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};
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 */
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 */
/* 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;
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;
/* 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);
}