]> git.sur5r.net Git - openldap/commitdiff
dn2idl API changed for consistency with other dn2id* funcs
authorPierangelo Masarati <ando@openldap.org>
Sat, 7 Jul 2001 14:49:42 +0000 (14:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 7 Jul 2001 14:49:42 +0000 (14:49 +0000)
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/proto-back-ldbm.h

index 088bc45bb033db5d4d113b7154ebada9e2978535..e680de1b56a4c0ada15391150b08d111bd3161a3 100644 (file)
@@ -203,16 +203,16 @@ dn2id(
        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,
@@ -221,6 +221,8 @@ dn2idl(
        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 ) {
@@ -232,7 +234,7 @@ dn2idl(
                        LDBM_SUFFIX, 0, 0 );
 #endif
 
-               return NULL;
+               return -1;
        }
 
        ldbm_datum_init( key );
@@ -241,13 +243,13 @@ dn2idl(
        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 );
 }
 
 
index 7ba65aae25aad091b16b4f37ad382855a87eac2d..f71c4f13ff8270e791fb283b36569782f8a30d61 100644 (file)
@@ -55,7 +55,12 @@ filter_candidates(
                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:
@@ -66,7 +71,12 @@ filter_candidates(
                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:
index 350120a3b0195569cc7b95430511653760903759..079c947756938c2028595b17681ac33994f532dd 100644 (file)
@@ -78,7 +78,7 @@ void *ldbm_cache_sync_daemon LDAP_P(( void *));
 
 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 ));