summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-02 22:40:31 +1000
committerAndrew Tridgell <tridge@samba.org>2009-10-02 22:40:31 +1000
commit35ff1f6f1f7f37dbc20668232728b54249e3d256 (patch)
tree936bf2b32ac14fd690fd8ae3601c150aaac98a9b
parenta0c82f17f897fcdbbd968d9808484ac577f93e20 (diff)
downloadsamba-35ff1f6f1f7f37dbc20668232728b54249e3d256.tar.gz
samba-35ff1f6f1f7f37dbc20668232728b54249e3d256.tar.bz2
samba-35ff1f6f1f7f37dbc20668232728b54249e3d256.zip
Revert "s4:ldb Fix ldb_list_find() folowing the change from char * to TDB_DATA"
This reverts commit f0c2c9854c7659221fe9480110a7d9b2b48afbf9.
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 7b8d2c249b..b959471d16 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -369,7 +369,7 @@ static int ldb_list_find(const void *needle,
const void *base, size_t nmemb, size_t size,
comparison_fn_t comp_fn)
{
- const uint8_t *base_p = (const uint8_t *)base;
+ const char *base_p = (const char *)base;
size_t min_i, max_i, test_i;
if (nmemb == 0) {
@@ -383,11 +383,17 @@ static int ldb_list_find(const void *needle,
int r;
test_i = (min_i + max_i) / 2;
- r = comp_fn(needle, (void const *)(base_p + (size * test_i)));
+ /* the following cast looks strange, but is
+ correct. The key to understanding it is that base_p
+ is a pointer to an array of pointers, so we have to
+ dereference it after casting to void **. The strange
+ const in the middle gives us the right type of pointer
+ after the dereference (tridge) */
+ r = comp_fn(needle, *(void * const *)(base_p + (size * test_i)));
if (r == 0) {
/* scan back for first element */
while (test_i > 0 &&
- comp_fn(needle, (void const *)(base_p + (size * (test_i-1)))) == 0) {
+ comp_fn(needle, *(void * const *)(base_p + (size * (test_i-1)))) == 0) {
test_i--;
}
return test_i;
@@ -403,7 +409,7 @@ static int ldb_list_find(const void *needle,
}
}
- if (comp_fn(needle, (void const *)(base_p + (size * min_i))) == 0) {
+ if (comp_fn(needle, *(void * const *)(base_p + (size * min_i))) == 0) {
return min_i;
}