From: Kurt Zeilenga Date: Thu, 28 Sep 2000 01:02:59 +0000 (+0000) Subject: Add idl_dump for testing purposes X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1870 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=75ee0afb30581fa4d30ab5ee281fe180b4940d4e;p=openldap Add idl_dump for testing purposes --- diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index fddb62d235..9007ab2448 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -14,6 +14,26 @@ #define IDL_CMP(x,y) ( x < y ? -1 : ( x > y ? 1 : 0 ) ) +#define IDL_DEBUG +#ifdef IDL_DEBUG +void idl_dump( ID *ids ) +{ + if( BDB_IDL_IS_RANGE( ids ) ) { + fprintf( stderr, "IDL: range %ld - %ld\n", (long) ids[0] ); + } else { + ID i; + fprintf( stderr, "IDL: size %ld", (long) ids[0] ); + + for( i=1; i<=ids[0]; i++ ) { + if( i % 16 ) fprintf( stderr, "\n" ); + fprintf( stderr, " %02lx" ); + } + + fprintf( stderr, "\n" ); + } +} +#endif + unsigned bdb_idl_search( ID *ids, ID id ) { #if BDB_IDL_BINARY_SEARCH @@ -66,6 +86,11 @@ static int idl_insert( ID *ids, ID id ) { unsigned x = bdb_idl_search( ids, id ); +#ifdef IDL_DEBUG + fprintf( stderr, "insert: %04lx at %d\n", id, x ); + idl_dump( ids ); +#endif + assert( x > 0 ); if( x < 1 ) { @@ -96,6 +121,10 @@ static int idl_insert( ID *ids, ID id ) ids[x] = id; } +#ifdef IDL_DEBUG + idl_dump( ids ); +#endif + return 0; } @@ -103,6 +132,11 @@ static int idl_delete( ID *ids, ID id ) { unsigned x = bdb_idl_search( ids, id ); +#ifdef IDL_DEBUG + fprintf( stderr, "delete: %04lx at %d\n", id, x ); + idl_dump( ids ); +#endif + assert( x > 0 ); if( x <= 0 ) { @@ -123,6 +157,10 @@ static int idl_delete( ID *ids, ID id ) AC_MEMCPY( &ids[x], &ids[x+1], (1+ids[0]-x) * sizeof(ID) ); } +#ifdef IDL_DEBUG + idl_dump( ids ); +#endif + return 0; }