Add IDL debugging code from SuSE.

This commit is contained in:
Kurt Zeilenga 2001-09-07 21:58:31 +00:00
parent 358835218a
commit cd51428dbe

View File

@ -45,6 +45,27 @@ static void cont_free( Datum *cont )
ch_free( cont->dptr );
}
#ifdef LDBM_DEBUG_IDL
static void idl_check(ID_BLOCK *idl)
{
int i;
ID_BLOCK last;
if( ID_BLOCK_INDIRECT(idl) || ID_BLOCK_ALLIDS(idl)
|| ID_BLOCK_NIDS(idl) <= 1 )
{
return;
}
for( last = ID_BLOCK_ID(idl, 0), i = 1;
i < ID_BLOCK_NIDS(idl);
last = ID_BLOCK_ID(idl, i), i++ )
{
assert (last < ID_BLOCK_ID(idl, i) );
}
}
#endif
/* Allocate an ID_BLOCK with room for nids ids */
ID_BLOCK *
idl_alloc( unsigned int nids )
@ -222,6 +243,10 @@ idl_fetch(
}
free( (char *) tmp );
#ifdef LDBM_DEBUG_IDL
idl_check(idl);
#endif
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
"idl_fetch: %ld ids (%ld max)\n",
@ -248,6 +273,10 @@ idl_store(
Datum data;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
#ifdef LDBM_DEBUG_IDL
idl_check(idl);
#endif
ldbm_datum_init( data );
/* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */
@ -312,6 +341,11 @@ idl_split_block(
(char *) &ID_BLOCK_ID(b, nr),
nl * sizeof(ID) );
ID_BLOCK_NIDS(*left) = nl + (nr == 0 ? 0 : 1);
#ifdef LDBM_DEBUG_IDL
idl_check(*right);
idl_check(*left);
#endif
}
@ -771,6 +805,10 @@ idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
'\0',
(ID_BLOCK_NMAX(*idl) - ID_BLOCK_NIDS(*idl)) * sizeof(ID) );
#ifdef LDBM_DEBUG_IDL
idl_check(*idl);
#endif
return( i == 0 ? 1 : 0 ); /* inserted - first id changed or not */
}
@ -911,6 +949,10 @@ idl_dup( ID_BLOCK *idl )
(char *) idl,
(ID_BLOCK_NMAX(idl) + ID_BLOCK_IDS_OFFSET) * sizeof(ID) );
#ifdef LDBM_DEBUG_IDL
idl_check(new);
#endif
return( new );
}
@ -948,6 +990,11 @@ idl_intersection(
n = idl_dup( idl_min( a, b ) );
#ifdef LDBM_DEBUG_IDL
idl_check(a);
idl_check(b);
#endif
for ( ni = 0, ai = 0, bi = 0; ai < ID_BLOCK_NIDS(a); ai++ ) {
for ( ;
bi < ID_BLOCK_NIDS(b) && ID_BLOCK_ID(b, bi) < ID_BLOCK_ID(a, ai);
@ -971,6 +1018,10 @@ idl_intersection(
}
ID_BLOCK_NIDS(n) = ni;
#ifdef LDBM_DEBUG_IDL
idl_check(n);
#endif
return( n );
}
@ -998,6 +1049,11 @@ idl_union(
return( idl_allids( be ) );
}
#ifdef LDBM_DEBUG_IDL
idl_check(a);
idl_check(b);
#endif
if ( ID_BLOCK_NIDS(b) < ID_BLOCK_NIDS(a) ) {
n = a;
a = b;
@ -1030,6 +1086,10 @@ idl_union(
}
ID_BLOCK_NIDS(n) = ni;
#ifdef LDBM_DEBUG_IDL
idl_check(n);
#endif
return( n );
}
@ -1107,6 +1167,10 @@ idl_notin(
}
ID_BLOCK_NIDS(n) = ni;
#ifdef LDBM_DEBUG_IDL
idl_check(n);
#endif
return( n );
}