diff options
-rw-r--r-- | test/sorted_array_test.c | 2 | ||||
-rw-r--r-- | zix/sorted_array.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/test/sorted_array_test.c b/test/sorted_array_test.c index 519ccb2..ad52db5 100644 --- a/test/sorted_array_test.c +++ b/test/sorted_array_test.c @@ -39,7 +39,7 @@ int_cmp(const void* a, const void* b, ZIX_UNUSED const void* user_data) return ia - ib; } -static uintptr_t +static intptr_t ith_elem(int test_num, unsigned n_elems, int i) { switch (test_num % 3) { diff --git a/zix/sorted_array.c b/zix/sorted_array.c index b2096b2..0f08e89 100644 --- a/zix/sorted_array.c +++ b/zix/sorted_array.c @@ -148,12 +148,12 @@ zix_sorted_array_find(const ZixSortedArray* a, const void* e, ZixSortedArrayIter* ai) { - uintptr_t lower = 0; - uintptr_t upper = (uintptr_t)a->num_elems - 1; + intptr_t lower = 0; + intptr_t upper = a->num_elems - 1; while (upper >= lower) { - const uintptr_t i = lower + ((upper - lower) / 2); - void* const elem_i = zix_sorted_array_index_unchecked(a, i); - const int cmp = a->cmp(elem_i, e, a->cmp_data); + const intptr_t i = lower + ((upper - lower) / 2); + void* const elem_i = zix_sorted_array_index_unchecked(a, i); + const int cmp = a->cmp(elem_i, e, a->cmp_data); if (cmp == 0) { *ai = elem_i; |