static void cont_id( Datum *cont, ID id )
{
- int i;
+ unsigned int i;
for( i=1; i <= sizeof(id); i++) {
((unsigned char *)cont->dptr)[i] = (unsigned char)(id & 0xFF);
{
if ( idl == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_free: called with NULL pointer\n" ));
#else
Debug( LDAP_DEBUG_TRACE,
if ( (tmp[i] = idl_fetch_one( be, db, data )) == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_fetch: idl_fetch_one returned NULL\n" ));
#else
Debug( LDAP_DEBUG_ANY,
#endif
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
+ LDAP_LOG(( "idl", LDAP_LEVEL_ENTRY,
"idl_fetch: %ld ids (%ld max)\n",
ID_BLOCK_NIDS(idl), ID_BLOCK_NMAXN(idl) ));
#else
/* delete old key block */
if ( (rc = ldbm_cache_delete( db, bkey )) != 0 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_change_first: ldbm_cache_delete returned %d\n", rc ));
#else
Debug( LDAP_DEBUG_ANY,
if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_change_first: idl_store returned %d\n", rc ));
#else
Debug( LDAP_DEBUG_ANY,
ID_BLOCK_ID(h, pos) = ID_BLOCK_ID(b, 0);
if ( (rc = idl_store( be, db, hkey, h )) != 0 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_change_first: idl_store returned %s\n", rc ));
#else
Debug( LDAP_DEBUG_ANY,
if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR,
"idl_insert_key: nonexistent continuation block\n" ));
#else
Debug( LDAP_DEBUG_ANY, "idl_insert_key: nonexistent continuation block\n",
case 0: /* id inserted ok */
if ( (rc = idl_store( be, db, k2, tmp )) != 0 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR,
"ids_insert_key: idl_store returned %d\n", rc ));
#else
Debug( LDAP_DEBUG_ANY,
cont_id( &k2, ID_BLOCK_ID(idl, i) );
if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR,
"idl_insert_key: idl_fetch_one returned NULL\n"));
#else
Debug( LDAP_DEBUG_ANY,
if ( (rc = idl_store( be, db, k2, tmp )) != 0 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR,
"idl_insert_key: idl_store returned %d\n", rc ));
#else
Debug( LDAP_DEBUG_ANY,
*/
if ( rc == 2 ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_insert_key: id %ld is already in next block\n",
id ));
#else
if ( (tmp = idl_fetch_one( be, db, data )) == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO,
"idl_delete_key: idl_fetch_one returned NULL\n" ));
#else
Debug( LDAP_DEBUG_ANY,
if ( ID_BLOCK_ALLIDS( b ) ) {
return( idl_dup( a ) );
}
+ if ( ID_BLOCK_NIDS(a) == 0 || ID_BLOCK_NIDS(b) == 0 ) {
+ return( NULL );
+ }
n = idl_dup( idl_min( a, b ) );
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);
- bi++ )
- {
- ; /* NULL */
- }
-
- if ( bi == ID_BLOCK_NIDS(b) ) {
- break;
- }
-
+ for ( ni = 0, ai = 0, bi = 0; ; ) {
if ( ID_BLOCK_ID(b, bi) == ID_BLOCK_ID(a, ai) ) {
ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
+ ai++;
+ bi++;
+ if ( ai >= ID_BLOCK_NIDS(a) || bi >= ID_BLOCK_NIDS(b) )
+ break;
+ } else if ( ID_BLOCK_ID(a, ai) < ID_BLOCK_ID(b, bi) ) {
+ ai++;
+ if ( ai >= ID_BLOCK_NIDS(a) )
+ break;
+ } else {
+ bi++;
+ if ( bi >= ID_BLOCK_NIDS(b) )
+ break;
}
}