return( 0 );
}
-ID_BLOCK *
+int
dn2idl(
Backend *be,
const char *dn,
- int prefix
+ int prefix,
+ ID_BLOCK **idlp
)
{
DBCache *db;
Datum key;
- ID_BLOCK *idl;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
Debug( LDAP_DEBUG_TRACE, "=> dn2idl( \"%c%s\" )\n", prefix, dn, 0 );
#endif
+ assert( idlp != NULL );
+ *idlp = NULL;
if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
== NULL ) {
LDBM_SUFFIX, 0, 0 );
#endif
- return NULL;
+ return -1;
}
ldbm_datum_init( key );
key.dptr = ch_malloc( key.dsize );
sprintf( key.dptr, "%c%s", prefix, dn );
- idl = idl_fetch( be, db, key );
+ *idlp = idl_fetch( be, db, key );
ldbm_cache_close( be, db );
free( key.dptr );
- return( idl );
+ return( 0 );
}
Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
#endif
- result = dn2idl( be, f->f_dn, DN_ONE_PREFIX );
+ /* an error is treated as an empty list */
+ if ( dn2idl( be, f->f_dn, DN_ONE_PREFIX, &result ) != 0
+ && result != NULL ) {
+ idl_free( result );
+ result = NULL;
+ }
break;
case SLAPD_FILTER_DN_SUBTREE:
Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
#endif
- result = dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX );
+ /* an error is treated as an empty list */
+ if ( dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX, &result ) != 0
+ && result != NULL ) {
+ idl_free( result );
+ result = NULL;
+ }
break;
case LDAP_FILTER_PRESENT:
int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id ));
int dn2id LDAP_P(( Backend *be, const char *dn, ID *idp ));
-ID_BLOCK *dn2idl LDAP_P(( Backend *be, const char *dn, int prefix ));
+int dn2idl LDAP_P(( Backend *be, const char *dn, int prefix, ID_BLOCK **idlp ));
int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id ));
Entry * dn2entry_rw LDAP_P(( Backend *be, const char *dn, Entry **matched, int rw ));