From 66337169f13592c85b15d18115893f5c8a53f866 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Aug 2006 07:20:32 +0000 Subject: r17771: add a comment explaing the odd cast (This used to be commit 47e695ed88d364a7d423e804fe5340006ebf7c18) --- source4/lib/ldb/ldb_tdb/ldb_index.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index c6feeaeb42..b628c31b09 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -61,6 +61,12 @@ static int ldb_list_find(const void *needle, int r; test_i = (min_i + max_i) / 2; + /* 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 */ -- cgit