]> git.sur5r.net Git - openldap/commitdiff
Moved AttributeDescription caching into main code:
authorHoward Chu <hyc@openldap.org>
Mon, 22 Oct 2001 13:23:05 +0000 (13:23 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 22 Oct 2001 13:23:05 +0000 (13:23 +0000)
   Changed AttributeDescription.{ad_cname,ad_lang} to struct berval everywhere
   Deleted ad_free() everywhere
   Added ad_mutex to init.c

The AttributeDescriptions are in a linked list hanging off of the
corresponding AttributeType.

50 files changed:
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/ad.c
servers/slapd/attr.c
servers/slapd/ava.c
servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-dnssrv/search.c
servers/slapd/back-ldap/add.c
servers/slapd/back-ldap/attribute.c
servers/slapd/back-ldap/compare.c
servers/slapd/back-ldap/group.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/search.c
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/attribute.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/group.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-meta/add.c
servers/slapd/back-meta/attribute.c
servers/slapd/back-meta/compare.c
servers/slapd/back-meta/group.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/search.c
servers/slapd/back-passwd/search.c
servers/slapd/back-shell/compare.c
servers/slapd/back-shell/modify.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/search.c
servers/slapd/back-sql/util.c
servers/slapd/backend.c
servers/slapd/compare.c
servers/slapd/entry.c
servers/slapd/filter.c
servers/slapd/init.c
servers/slapd/modify.c
servers/slapd/mods.c
servers/slapd/mra.c
servers/slapd/proto-slap.h
servers/slapd/repl.c
servers/slapd/result.c
servers/slapd/saslauthz.c
servers/slapd/schema_check.c
servers/slapd/slap.h

index 9ae0246de216a09c5553b6ebfa6d6dfb357776f2..9dbe23de9eb7f6d5daecf42fdb79c45d90f863d2 100644 (file)
@@ -94,7 +94,7 @@ access_allowed(
        assert( desc != NULL );
        assert( access > ACL_NONE );
 
-       attr = desc->ad_cname->bv_val;
+       attr = desc->ad_cname.bv_val;
 
        assert( attr != NULL );
 
@@ -292,7 +292,7 @@ acl_get(
        assert( count != NULL );
        assert( desc != NULL );
 
-       attr = desc->ad_cname->bv_val;
+       attr = desc->ad_cname.bv_val;
 
        assert( attr != NULL );
 
@@ -463,7 +463,7 @@ acl_mask(
        assert( mask != NULL );
        assert( desc != NULL );
 
-       attr = desc->ad_cname->bv_val;
+       attr = desc->ad_cname.bv_val;
 
        assert( attr != NULL );
 
@@ -685,7 +685,7 @@ acl_mask(
                        struct berval   bv;
                        int rc, match = 0;
                        const char *text;
-                       const char *attr = b->a_dn_at->ad_cname->bv_val;
+                       const char *attr = b->a_dn_at->ad_cname.bv_val;
 
                        assert( attr != NULL );
 
@@ -1081,11 +1081,11 @@ acl_check_modlist(
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
                                   "acl_check_modlist: conn %d  no-user-mod %s: modify access granted\n",
-                                  conn->c_connid, mlist->sml_desc->ad_cname->bv_val ));
+                                  conn->c_connid, mlist->sml_desc->ad_cname.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
                                " modify access granted\n",
-                               mlist->sml_desc->ad_cname->bv_val, 0, 0 );
+                               mlist->sml_desc->ad_cname.bv_val, 0, 0 );
 #endif
                        continue;
                }
@@ -1236,7 +1236,6 @@ aci_set_gather (void *cookie, char *name, char *attr)
                                        }
                                        ber_bvecfree(bvals);
                                }
-                               ad_free(desc, 1);
                        }
                }
                ch_free(ndn);
@@ -1294,7 +1293,6 @@ aci_match_set (
                        {
                                backend_attribute(be, NULL, NULL, e,
                                                                subjdn, desc, &bvals);
-                               ad_free(desc, 1);
                                if ( bvals != NULL ) {
                                        if ( bvals[0] != NULL )
                                                set = ch_strdup(bvals[0]->bv_val);
@@ -1533,7 +1531,6 @@ aci_group_member (
        }
 
 done:
-       if( grp_ad != NULL ) ad_free( grp_ad, 1 );
        ch_free(grpdn);
        ch_free(grpat);
        ch_free(grpoc);
@@ -1558,7 +1555,7 @@ aci_mask(
     struct berval bv, perms, sdn;
     char *subjdn;
        int rc;
-       char *attr = desc->ad_cname->bv_val;
+       char *attr = desc->ad_cname.bv_val;
 
        assert( attr != NULL );
 
@@ -1645,7 +1642,6 @@ aci_mask(
                        }
                }
 
-               ad_free( ad, 1 );
                return rc;
 
 
index a7df30bd8e71c844aa9e9e27501ced2d6d536221..c18f36e27f3559bde7306282e50c8025d53b6587 100644 (file)
@@ -539,7 +539,7 @@ parse_acl(
                                                        fprintf( stderr,
                                                                "%s: line %d: group: \"%s\" not allowed by \"%s\"\n",
                                                                fname, lineno,
-                                                               b->a_group_at->ad_cname->bv_val,
+                                                               b->a_group_at->ad_cname.bv_val,
                                                                b->a_group_oc->soc_oid );
                                                        acl_usage();
                                                }
@@ -1200,7 +1200,7 @@ print_access( Access *b )
        }
 
        if ( b->a_dn_at != NULL ) {
-               fprintf( stderr, " dnattr=%s", b->a_dn_at->ad_cname->bv_val );
+               fprintf( stderr, " dnattr=%s", b->a_dn_at->ad_cname.bv_val );
        }
 
        if ( b->a_group_pat != NULL ) {
@@ -1211,7 +1211,7 @@ print_access( Access *b )
                                b->a_group_oc->soc_oclass.oc_oid );
 
                        if ( b->a_group_at ) {
-                               fprintf( stderr, " attributeType: %s", b->a_group_at->ad_cname->bv_val );
+                               fprintf( stderr, " attributeType: %s", b->a_group_at->ad_cname.bv_val );
                        }
                }
     }
@@ -1234,7 +1234,7 @@ print_access( Access *b )
 
 #ifdef SLAPD_ACI_ENABLED
        if ( b->a_aci_at != NULL ) {
-               fprintf( stderr, " aci=%s", b->a_aci_at->ad_cname->bv_val );
+               fprintf( stderr, " aci=%s", b->a_aci_at->ad_cname.bv_val );
        }
 #endif
 
index e2a028c90df5b96331e94331de6a4f2249685592..7ea0734aab6d467b774c2a04ea7c126b59c871c1 100644 (file)
 #include "ldap_pvt.h"
 #include "slap.h"
 
-AttributeDescription *ad_dup(
-       AttributeDescription *desc )
-{
-       AttributeDescription *ad;
-
-       if( desc == NULL ) {
-               return NULL;
-       }
-
-       ad = (AttributeDescription *) ch_malloc( sizeof(AttributeDescription) );
-
-       *ad = *desc;
-
-       if( ad->ad_cname != NULL ) {
-               ad->ad_cname = ber_bvdup( ad->ad_cname );
-       }
-
-       if( ad->ad_lang != NULL ) {
-               ad->ad_lang = ch_strdup( ad->ad_lang );
-       }
-
-       return ad;
-}
-
-void
-ad_free( AttributeDescription *ad, int freeit )
-{
-       if( ad == NULL ) return;
-
-       if( ad->ad_cname != NULL ) {
-               ber_bvfree( ad->ad_cname );
-       }
-
-       free( ad->ad_lang );
-
-       if( freeit ) free( ad );
-}
+extern ldap_pvt_thread_mutex_t ad_mutex;       /* init.c */
 
 static int ad_keystring(
        struct berval *bv )
@@ -92,8 +56,8 @@ int slap_bv2ad(
 {
        int rtn = LDAP_UNDEFINED_TYPE;
        int i;
-       AttributeDescription desc;
-       char **tokens;
+       AttributeDescription desc, *d2;
+       char *name, *options;
 
        assert( ad != NULL );
        assert( *ad == NULL ); /* temporary */
@@ -109,25 +73,37 @@ int slap_bv2ad(
                return rtn;
        }
 
-       tokens = str2charray( bv->bv_val, ";");
-
-       if( tokens == NULL || *tokens == NULL ) {
-               *text = "no attribute type";
-               goto done;
-       }
-
-       desc.ad_type = at_find( *tokens );
-
+       /* find valid base attribute type; parse in place */
+       name = bv->bv_val;
+       options = strchr(name, ';');
+       if (options != NULL) *options = '\0';
+       desc.ad_type = at_find( name );
+       if (options != NULL) *options = ';';
        if( desc.ad_type == NULL ) {
                *text = "attribute type undefined";
-               goto done;
+
+               return rtn;
        }
 
-       desc.ad_flags = SLAP_DESC_NONE;
-       desc.ad_lang = NULL;
+       if (options != NULL)
+               desc.ad_cname.bv_len = options - name;
+       else
+               desc.ad_cname.bv_len = strlen(name);
 
-       for( i=1; tokens[i] != NULL; i++ ) {
-               if( strcasecmp( tokens[i], "binary" ) == 0 ) {
+       desc.ad_flags = SLAP_DESC_NONE;
+       desc.ad_lang.bv_len = 0;
+       desc.ad_lang.bv_val = NULL;
+
+       /* parse options in place */
+       for( ; options != NULL; ) {
+               name = options+1;
+               options = strchr( name, ';' );
+               if ( options != NULL )
+                       i = options - name;
+               else
+                       i = strlen(name);
+
+               if( i == sizeof("binary")-1 && strncasecmp( name, "binary", i) == 0 ) {
                        if( slap_ad_is_binary( &desc ) ) {
                                *text = "option \"binary\" specified multiple times";
                                goto done;
@@ -141,57 +117,126 @@ int slap_bv2ad(
 
                        desc.ad_flags |= SLAP_DESC_BINARY;
 
-               } else if ( strncasecmp( tokens[i], "lang-",
-                       sizeof("lang-")-1 ) == 0 && tokens[i][sizeof("lang-")-1] )
+               } else if ( i >= sizeof("lang-") && strncasecmp( name, "lang-",
+                       sizeof("lang-")-1 ) == 0)
                {
-                       if( desc.ad_lang != NULL ) {
+                       if( desc.ad_lang.bv_len != 0 ) {
                                *text = "multiple language tag options specified";
                                goto done;
                        }
 
-                       desc.ad_lang = ch_strdup( tokens[i] );
-
-                       /* normalize to all lower case, it's easy */
-                       ldap_pvt_str2lower( desc.ad_lang );
-
+                       desc.ad_lang.bv_val = name;
+                       desc.ad_lang.bv_len = i;
                } else {
                        *text = "unrecognized option";
                        goto done;
                }
        }
 
-       desc.ad_cname = ch_malloc( sizeof( struct berval ) );
-
-       desc.ad_cname->bv_len = strlen( desc.ad_type->sat_cname );
-       if( slap_ad_is_binary( &desc ) ) {
-               desc.ad_cname->bv_len += sizeof("binary");
-       }
-       if( desc.ad_lang != NULL ) {
-               desc.ad_cname->bv_len += 1 + strlen( desc.ad_lang );
+       /* see if a matching description is already cached */
+       for (d2 = desc.ad_type->sat_ad; d2; d2=d2->ad_next) {
+               if (d2->ad_flags != desc.ad_flags)
+                       continue;
+               if (d2->ad_lang.bv_len != desc.ad_lang.bv_len)
+                       continue;
+               if (d2->ad_lang.bv_len == 0)
+                       break;
+               if (strncasecmp(d2->ad_lang.bv_val, desc.ad_lang.bv_val,
+                       desc.ad_lang.bv_len) == 0)
+                       break;
        }
 
-       desc.ad_cname->bv_val = ch_malloc( desc.ad_cname->bv_len + 1 );
+       /* Not found, add new one */
+       while (d2 == NULL) {
+               int dlen = 0;
+               /* uses a single mutex instead of one per attributetype.
+                * I don't believe this is a significant bottleneck. If
+                * necessary, could change to a per-AttrType rwlock.
+                */
+               ldap_pvt_thread_mutex_lock( &ad_mutex );
+               /* Check again just in case another thread added it */
+               for (d2 = desc.ad_type->sat_ad; d2; d2=d2->ad_next) {
+                       if (d2->ad_flags != desc.ad_flags)
+                               continue;
+                       if (d2->ad_lang.bv_len != desc.ad_lang.bv_len)
+                               continue;
+                       if (d2->ad_lang.bv_len == 0)
+                               break;
+                       if (strncasecmp(d2->ad_lang.bv_val,desc.ad_lang.bv_val,
+                               desc.ad_lang.bv_len) == 0)
+                               break;
+               }
+               /* Some other thread added it before we got the lock. */
+               if (d2 != NULL) {
+                       ldap_pvt_thread_mutex_unlock( &ad_mutex );
+                       break;
+               }
 
-       strcpy( desc.ad_cname->bv_val, desc.ad_type->sat_cname );
-       if( slap_ad_is_binary( &desc ) ) {
-               strcat( desc.ad_cname->bv_val, ";binary" );
-       }
+               /* Allocate a single contiguous block. If there are no
+                * options, we just need space for the AttrDesc structure.
+                * Otherwise, we need to tack on the full name length +
+                * options length.
+                */
+               i = sizeof(AttributeDescription);
+               if (desc.ad_lang.bv_len || desc.ad_flags != SLAP_DESC_NONE) {
+                       if (desc.ad_lang.bv_len)
+                               dlen = desc.ad_lang.bv_len+1;
+                       dlen += strlen(desc.ad_type->sat_cname)+1;
+                       if( slap_ad_is_binary( &desc ) ) {
+                               dlen += sizeof("binary");
+                       }
+               }
 
-       if( desc.ad_lang != NULL ) {
-               strcat( desc.ad_cname->bv_val, ";" );
-               strcat( desc.ad_cname->bv_val, desc.ad_lang );
+               d2 = ch_malloc(i + dlen);
+               d2->ad_type = desc.ad_type;
+               d2->ad_flags = desc.ad_flags;
+               d2->ad_cname.bv_len = desc.ad_cname.bv_len;
+               d2->ad_lang.bv_len = desc.ad_lang.bv_len;
+               if (dlen == 0) {
+                       d2->ad_cname.bv_val = d2->ad_type->sat_cname;
+                       d2->ad_lang.bv_val = NULL;
+               } else {
+                       d2->ad_cname.bv_val = (char *)(d2+1);
+                       strcpy(d2->ad_cname.bv_val, d2->ad_type->sat_cname);
+                       if( slap_ad_is_binary( &desc ) ) {
+                               strcpy(d2->ad_cname.bv_val+d2->ad_cname.bv_len,
+                                       ";binary");
+                               d2->ad_cname.bv_len += sizeof("binary");
+                       }
+                       if( d2->ad_lang.bv_len ) {
+                               d2->ad_cname.bv_val[d2->ad_cname.bv_len++]=';';
+                               d2->ad_lang.bv_val = d2->ad_cname.bv_val+
+                                       d2->ad_cname.bv_len;
+                               strncpy(d2->ad_lang.bv_val,desc.ad_lang.bv_val,
+                                       d2->ad_lang.bv_len);
+                               d2->ad_lang.bv_val[d2->ad_lang.bv_len] = '\0';
+                               ldap_pvt_str2lower(d2->ad_lang.bv_val);
+                               d2->ad_cname.bv_len += d2->ad_lang.bv_len;
+                       }
+               }
+               /* Add new desc to list. We always want the bare Desc with
+                * no options to stay at the head of the list, assuming
+                * that one will be used most frequently.
+                */
+               if (desc.ad_type->sat_ad == NULL || dlen == 0) {
+                       d2->ad_next = desc.ad_type->sat_ad;
+                       desc.ad_type->sat_ad = d2;
+               } else {
+                       d2->ad_next = desc.ad_type->sat_ad->ad_next;
+                       desc.ad_type->sat_ad->ad_next = d2;
+               }
+               ldap_pvt_thread_mutex_unlock( &ad_mutex );
        }
 
        if( *ad == NULL ) {
-               *ad = ch_malloc( sizeof( AttributeDescription ) );
+               *ad = d2;
+       } else {
+               **ad = *d2;
        }
 
-       **ad = desc;
-
        rtn = LDAP_SUCCESS;
 
 done:
-       charray_free( tokens );
        return rtn;
 }
 
@@ -208,8 +253,9 @@ int is_ad_subtype(
                return 0;
        }
 
-       if( super->ad_lang != NULL && ( sub->ad_lang == NULL
-               || strcasecmp( super->ad_lang, sub->ad_lang )))
+       if( super->ad_lang.bv_len && (sub->ad_lang.bv_len !=
+               super->ad_lang.bv_len || strcmp( super->ad_lang.bv_val,
+               sub->ad_lang.bv_val)))
        {
                return 0;
        }
@@ -234,8 +280,6 @@ int ad_inlist(
 
                rc = is_ad_subtype( desc, ad );
 
-               ad_free( ad, 1 );
-
                if( rc ) return 1;
        }
 
@@ -260,10 +304,9 @@ int slap_bv2undef_ad(
        AttributeDescription **ad,
        const char **text )
 {
-       AttributeDescription desc;
+       AttributeDescription *desc;
 
        assert( ad != NULL );
-       assert( *ad == NULL ); /* temporary */
 
        if( bv == NULL || bv->bv_len == 0 ) {
                *text = "empty attribute description";
@@ -276,21 +319,36 @@ int slap_bv2undef_ad(
                return LDAP_UNDEFINED_TYPE;
        }
 
-       desc.ad_type = slap_schema.si_at_undefined;
-       desc.ad_flags = SLAP_DESC_NONE;
-       desc.ad_lang = NULL;
+       for (desc = slap_schema.si_at_undefined->sat_ad; desc;
+               desc=desc->ad_next)
+               if (desc->ad_cname.bv_len == bv->bv_len &&
+                   !strcasecmp(desc->ad_cname.bv_val, bv->bv_val))
+                       break;
+       
+       if (!desc) {
+               desc = ch_malloc(sizeof(AttributeDescription) +
+                       bv->bv_len + 1);
+               
+               desc->ad_flags = SLAP_DESC_NONE;
+               desc->ad_lang.bv_val = NULL;
+               desc->ad_lang.bv_len = 0;
 
-       desc.ad_cname = ber_bvdup( bv );
+               desc->ad_cname.bv_len = bv->bv_len;
+               desc->ad_cname.bv_val = (char *)(desc+1);
+               strcpy(desc->ad_cname.bv_val, bv->bv_val);
 
-       /* canoncial to upper case */
-       ldap_pvt_str2upper( bv->bv_val );
+               /* canonical to upper case */
+               ldap_pvt_str2upper( desc->ad_cname.bv_val );
 
-       if( *ad == NULL ) {
-               *ad = ch_malloc( sizeof( AttributeDescription ) );
+               desc->ad_type = slap_schema.si_at_undefined;
+               desc->ad_next = desc->ad_type->sat_ad;
+               desc->ad_type->sat_ad = desc;
        }
 
-       **ad = desc;
+       if (!*ad)
+               *ad = desc;
+       else
+               **ad = *desc;
 
        return LDAP_SUCCESS;
 }
-
index 9239e161f812e6c378608858e8c8f7ec2edcb634..d5b9e3a0780acf2afe41d2cc18c4103426becd48 100644 (file)
@@ -29,7 +29,6 @@ static void at_index_print( void );
 void
 attr_free( Attribute *a )
 {
-       ad_free( a->a_desc, 1 );
        ber_bvecfree( a->a_vals );
        free( a );
 }
@@ -74,7 +73,7 @@ Attribute *attr_dup( Attribute *a )
                tmp->a_vals = NULL;
        }
 
-       tmp->a_desc = ad_dup( a->a_desc );
+       tmp->a_desc = a->a_desc;
        tmp->a_next = NULL;
 
        return tmp;
@@ -124,7 +123,7 @@ attr_merge(
 
        if ( *a == NULL ) {
                *a = (Attribute *) ch_malloc( sizeof(Attribute) );
-               (*a)->a_desc = ad_dup( desc );
+               (*a)->a_desc = desc;
                (*a)->a_vals = NULL;
                (*a)->a_next = NULL;
        }
index 69157a954a278a91bc1bf4acf94f4573872ae089..da6a2e3355ae37a296b8e9b24387ad04d394e690 100644 (file)
@@ -21,7 +21,6 @@ ava_free(
     int        freeit
 )
 {
-       ad_free( ava->aa_desc, 1 );
        ber_bvfree( ava->aa_value );
        if ( freeit ) {
                ch_free( (char *) ava );
@@ -70,7 +69,6 @@ get_ava(
        ch_free( value.bv_val );
 
        if( rc != LDAP_SUCCESS ) {
-               ad_free( aa->aa_desc, 1 );
                ch_free( aa );
                return rc;
        }
index 66c77242cd67bbb7451c89dc747345394878b52e..dd1fe3b851c63a2a6e8e4321433bcd9c98041405 100644 (file)
@@ -203,18 +203,17 @@ bdb_attr_index_config(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                           "attr_index_config: index %s 0x%04x\n",
-                          ad->ad_cname->bv_val, mask ));
+                          ad->ad_cname.bv_val, mask ));
 #else
                Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04x\n",
-                       ad->ad_cname->bv_val, mask, 0 ); 
+                       ad->ad_cname.bv_val, mask, 0 ); 
 #endif
 
 
 #ifdef SLAPD_USE_AD
                a->ai_desc = ad;
 #else
-               a->ai_desc = ch_strdup( ad->ad_cname->bv_val );
-               ad_free( ad, 1 );
+               a->ai_desc = ch_strdup( ad->ad_cname.bv_val );
 #endif
 
                a->ai_indexmask = mask;
@@ -242,9 +241,7 @@ static void
 ainfo_free( void *attr )
 {
        AttrInfo *ai = attr;
-#ifdef SLAPD_USE_AD
-       ad_free( ai->ai_desc, 1 );
-#else
+#ifndef SLAPD_USE_AD
        free( ai->ai_desc );
 #endif
        free( ai );
index 538249eb34bca0e42a888f4c4fc1215e86755a3d..8c02c77b3c184dd4c405e4b7b4ca4bced4697d52 100644 (file)
@@ -26,7 +26,7 @@ ad_type_cmp(
        AttributeDescription *ad
 )
 {
-       return strcasecmp(desc, ad->ad_cname->bv_val);
+       return strcasecmp(desc, ad->ad_cname.bv_val);
 }
 
 static int
@@ -35,7 +35,7 @@ ad_info_cmp(
        AttributeDescription *a2
 )
 {
-       return strcasecmp(a1->ad_cname->bv_val, a2->ad_cname->bv_val);
+       return strcasecmp(a1->ad_cname.bv_val, a2->ad_cname.bv_val);
 }
 
 AttributeDescription *
@@ -87,7 +87,7 @@ int bdb_encode(Entry *e, struct berval **bv)
        for (a=e->e_attrs; a; a=a->a_next) {
                /* For AttributeDesc, we only store the attr name */
                siz += sizeof(Attribute);
-               len += a->a_desc->ad_cname->bv_len+1;
+               len += a->a_desc->ad_cname.bv_len+1;
                for (i=0; a->a_vals[i]; i++) {
                        siz += sizeof(struct berval *);
                        siz += sizeof(struct berval);
@@ -116,9 +116,9 @@ int bdb_encode(Entry *e, struct berval **bv)
                b = (Attribute *)data;
                data = (char *)(b+1);
                b->a_desc = (AttributeDescription *)(ptr-base);
-               memcpy(ptr, a->a_desc->ad_cname->bv_val,
-                       a->a_desc->ad_cname->bv_len);
-               ptr += a->a_desc->ad_cname->bv_len;
+               memcpy(ptr, a->a_desc->ad_cname.bv_val,
+                       a->a_desc->ad_cname.bv_len);
+               ptr += a->a_desc->ad_cname.bv_len;
                *ptr++ = '\0';
                if (a->a_vals) {
                    bvl = (struct berval **)data;
index eb259c5efdf29af02b23f5a92ea487d6fe5184f6..71e902e764639949e401114acabfe4329f5f4add 100644 (file)
@@ -27,11 +27,11 @@ static slap_mask_t index_mask(
        /* we do not support indexing of binary attributes */
        if( slap_ad_is_binary( desc ) ) return 0;
 
-       bdb_attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
+       bdb_attr_mask( be->be_private, desc->ad_cname.bv_val, &mask );
 
        if( mask ) {
-               *atname = desc->ad_cname->bv_val;
-               *dbname = desc->ad_cname->bv_val;
+               *atname = desc->ad_cname.bv_val;
+               *dbname = desc->ad_cname.bv_val;
                return mask;
        }
 
@@ -40,7 +40,7 @@ static slap_mask_t index_mask(
                bdb_attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
 
                if( mask & SLAP_INDEX_AUTO_LANG ) {
-                       *atname = desc->ad_cname->bv_val;
+                       *atname = desc->ad_cname.bv_val;
                        *dbname = desc->ad_type->sat_cname;
                        return mask;
                }
@@ -248,7 +248,6 @@ static int indexer(
        }
 
 done:
-       ad_free( ad, 1 );
        return rc;
 }
 
@@ -256,7 +255,7 @@ static int index_at_values(
        Backend *be,
        DB_TXN *txn,
        AttributeType *type,
-       const char *lang,
+       struct berval *lang,
        struct berval **vals,
        ID id,
        int op,
@@ -295,13 +294,13 @@ static int index_at_values(
                if( rc ) return rc;
        }
 
-       if( lang ) {
+       if( lang->bv_len ) {
                char *dbname = NULL;
                size_t tlen = strlen( type->sat_cname );
-               size_t llen = strlen( lang );
+               size_t llen = lang->bv_len;
                char *lname = ch_malloc( tlen + llen + sizeof(";") );
 
-               sprintf( lname, "%s;%s", type->sat_cname, lang );
+               sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val );
 
                bdb_attr_mask( be->be_private, lname, &tmpmask );
 
@@ -347,7 +346,7 @@ int bdb_index_values(
        }
 
        rc = index_at_values( be, txn,
-               desc->ad_type, desc->ad_lang,
+               desc->ad_type, &desc->ad_lang,
                vals, id, op,
                &dbname, &mask );
 
index 279a8776a1459437dfe5cf824034668416b6c427..5bcd494e783e4978ae12d1589415b087019b628f 100644 (file)
@@ -354,7 +354,7 @@ add_values(
        int             i;
        Attribute       *a;
 
-       /* char *desc = mod->sm_desc->ad_cname->bv_val; */
+       /* char *desc = mod->sm_desc->ad_cname.bv_val; */
        MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
 
        a = attr_find( e->e_attrs, mod->sm_desc );
@@ -415,7 +415,7 @@ delete_values(
 {
        int             i, j, k, found;
        Attribute       *a;
-       char *desc = mod->sm_desc->ad_cname->bv_val;
+       char *desc = mod->sm_desc->ad_cname.bv_val;
        MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
 
        /* delete the entire attribute */
index 3da231e2310874f4bf026a782809b67982f9c539..b2e989c42628c7432bfaafa36faa6abc5cae6428 100644 (file)
@@ -397,7 +397,6 @@ retry:      /* transaction retry */
                                "bdb_modrdn: access to attr \"%s\" "
                                "(new) not allowed\n", 
                                new_rdn_types[ a_cnt ], 0, 0 );
-                       ad_free( desc, 1);
                        rc = LDAP_INSUFFICIENT_ACCESS;
                        goto return_results;
                }
@@ -450,7 +449,6 @@ retry:      /* transaction retry */
                                        "bdb_modrdn: access to attr \"%s\" "
                                        "(old) not allowed\n", 
                                        old_rdn_types[ d_cnt ], 0, 0 );
-                               ad_free( desc, 1);
                                rc = LDAP_INSUFFICIENT_ACCESS;
                                goto return_results;
                        }
index 28f32d3a1e550a99c04a149c1c504b1de0258045..ba1d6816b75d8258f09e399d431c5c5a49878c97 100644 (file)
@@ -176,8 +176,6 @@ dnssrv_back_search(
 
                                val.bv_len = strlen(val.bv_val);
                                attr_merge( e, ad, vals );
-
-                               ad_free( ad, 1 );
                        }
                }
 
@@ -191,8 +189,6 @@ dnssrv_back_search(
                                val.bv_val = domain;
                                val.bv_len = strlen(domain);
                                attr_merge( e, ad, vals );
-
-                               ad_free( ad, 1 );
                        }
                }
 
index 32fc5bb9102c4cd417a946a97f77707a4235d7a6..d5c3ad0cb99755811721f65b3d46447fb0358158 100644 (file)
@@ -119,20 +119,20 @@ ldap_back_add(
                 * of the target directory are used, if available
                 */
 #if 0
-               if ( !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_creatorsName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_createTimestamp->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifiersName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val )
+               if ( !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_creatorsName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_createTimestamp->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifiersName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val )
                ) {
                        continue;
                }
 #endif
                
-               mapped = ldap_back_map(&li->at_map, a->a_desc->ad_cname->bv_val, 0);
+               mapped = ldap_back_map(&li->at_map, a->a_desc->ad_cname.bv_val, 0);
                if (mapped == NULL) {
                        continue;
                }
index e8b49e052adcbdf5d03e78c9d3f3d6075e506d30..3fe917754ca1dbc9031cf0ce7e6c3880e18cdfee 100644 (file)
@@ -62,7 +62,7 @@ ldap_back_attribute(
                }
 
        } else {
-               mapped = ldap_back_map(&li->at_map, entry_at->ad_cname->bv_val, 0);
+               mapped = ldap_back_map(&li->at_map, entry_at->ad_cname.bv_val, 0);
                if (mapped == NULL)
                        return(1);
 
index 23d65f9e5635065921b6b99da1930b7ac3e80799..21bc19279b920b5b8280526bebf4d00e9d388c80 100644 (file)
@@ -100,7 +100,7 @@ ldap_back_compare(
        }
 #endif /* !ENABLE_REWRITE */
 
-       mapped_oc = ldap_back_map(&li->oc_map, ava->aa_desc->ad_cname->bv_val, 0);
+       mapped_oc = ldap_back_map(&li->oc_map, ava->aa_desc->ad_cname.bv_val, 0);
        if (mapped_oc == NULL)
                return( -1 );
 
index a8a167766b246b1f3c87ea219bd4b8e9c6902206..2080f64c15b937aa975b199b23b323f0f17ae9f3 100644 (file)
@@ -45,7 +45,7 @@ ldap_back_group(
 
        AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
        char *group_oc_name = NULL;
-       char *group_at_name = group_at->ad_cname->bv_val;
+       char *group_at_name = group_at->ad_cname.bv_val;
 
        if( group_oc->soc_names && group_oc->soc_names[0] ) {
                group_oc_name = group_oc->soc_names[0];
index a59d4179ca27452be7703eb4faf90a7844f364ed..e1e54052f997be4312f0dc1af7a75ecdca146c96 100644 (file)
@@ -113,7 +113,7 @@ ldap_back_modify(
        }
 
        for (i=0, ml=modlist; ml; ml=ml->sml_next) {
-               mapped = ldap_back_map(&li->at_map, ml->sml_desc->ad_cname->bv_val, 0);
+               mapped = ldap_back_map(&li->at_map, ml->sml_desc->ad_cname.bv_val, 0);
                if (mapped == NULL) {
                        continue;
                }
index fa35d582e5e804d2e8e3997113def4bee34d44c2..0de3e828fc493392090ace3b29bc5cddefb9bdf6 100644 (file)
@@ -543,7 +543,6 @@ ldap_send_entry(
        while (ent.e_attrs) {
                attr = ent.e_attrs;
                ent.e_attrs = attr->a_next;
-               ad_free(attr->a_desc, 1);
                if (attr->a_vals != &dummy)
                        ber_bvecfree(attr->a_vals);
                free(attr);
index f642aedec9d834a0c7e84fb260331efc792a7958..7aef298fa590f3b080fc4d51cd3bdafd9a7b9934 100644 (file)
@@ -204,18 +204,17 @@ attr_index_config(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                           "attr_index_config: index %s 0x%04x\n",
-                          ad->ad_cname->bv_val, mask ));
+                          ad->ad_cname.bv_val, mask ));
 #else
                Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04x\n",
-                       ad->ad_cname->bv_val, mask, 0 ); 
+                       ad->ad_cname.bv_val, mask, 0 ); 
 #endif
 
 
 #ifdef SLAPD_USE_AD
                a->ai_desc = ad;
 #else
-               a->ai_desc = ch_strdup( ad->ad_cname->bv_val );
-               ad_free( ad, 1 );
+               a->ai_desc = ch_strdup( ad->ad_cname.bv_val );
 #endif
 
                a->ai_indexmask = mask;
@@ -243,9 +242,7 @@ static void
 ainfo_free( void *attr )
 {
        AttrInfo *ai = attr;
-#ifdef SLAPD_USE_AD
-       ad_free( ai->ai_desc, 1 );
-#else
+#ifndef SLAPD_USE_AD
        free( ai->ai_desc );
 #endif
        free( ai );
index bad3eed2e20b709588a201a414c4592e854fa297..9dffdce630f3cc1fbfbde2e7e93a9480b69105ef 100644 (file)
@@ -35,7 +35,7 @@ ldbm_back_attribute(
        int          i, j, rc;
        Attribute   *attr;
        struct berval **v;
-       const char *entry_at_name = entry_at->ad_cname->bv_val;
+       const char *entry_at_name = entry_at->ad_cname.bv_val;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "backend", LDAP_LEVEL_ARGS,
index c6df7e2d2c1b7bb7c91350a0a4a5351c43055253..8732599d74840b7ff0e3b693ef11492ac56a4144 100644 (file)
@@ -82,7 +82,7 @@ filter_candidates(
        case LDAP_FILTER_PRESENT:
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
-                          "filter_candidates:  Present (%s)\n", f->f_desc->ad_cname->bv_val ));
+                          "filter_candidates:  Present (%s)\n", f->f_desc->ad_cname.bv_val ));
 #else
                Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 );
 #endif
@@ -94,7 +94,7 @@ filter_candidates(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
                           "filter_candidates:  EQUALITY (%s),(%s)\n",
-                          f->f_ava->aa_desc->ad_cname->bv_val,
+                          f->f_ava->aa_desc->ad_cname.bv_val,
                           f->f_ava->aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
@@ -107,7 +107,7 @@ filter_candidates(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
                           "filter_candidates:  APPROX (%s), (%s)\n",
-                          f->f_ava->aa_desc->ad_cname->bv_val,
+                          f->f_ava->aa_desc->ad_cname.bv_val,
                           f->f_ava->aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
index ff597f41f9dc5b8a287d49bed544762dd2494d28..2de91fd5e88d733d15d307512317ddae8fde4676 100644 (file)
@@ -41,7 +41,7 @@ ldbm_back_group(
 
        AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
        const char *group_oc_name = NULL;
-       const char *group_at_name = group_at->ad_cname->bv_val;
+       const char *group_at_name = group_at->ad_cname.bv_val;
 
        if( group_oc->soc_names && group_oc->soc_names[0] ) {
                group_oc_name = group_oc->soc_names[0];
index f24903003d4d7d78c1e66532b34d0fc2adf4360c..54ad4442b7c8d3ea26158ad7cb81d5a66f2a5ecc 100644 (file)
@@ -27,11 +27,11 @@ static slap_mask_t index_mask(
        /* we do not support indexing of binary attributes */
        if( slap_ad_is_binary( desc ) ) return 0;
 
-       attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
+       attr_mask( be->be_private, desc->ad_cname.bv_val, &mask );
 
        if( mask ) {
-               *atname = desc->ad_cname->bv_val;
-               *dbname = desc->ad_cname->bv_val;
+               *atname = desc->ad_cname.bv_val;
+               *dbname = desc->ad_cname.bv_val;
                return mask;
        }
 
@@ -40,7 +40,7 @@ static slap_mask_t index_mask(
                attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
 
                if( mask & SLAP_INDEX_AUTO_LANG ) {
-                       *atname = desc->ad_cname->bv_val;
+                       *atname = desc->ad_cname.bv_val;
                        *dbname = desc->ad_type->sat_cname;
                        return mask;
                }
@@ -166,7 +166,6 @@ static int indexer(
                        dbname, LDBM_SUFFIX, 0 );
 #endif
 
-               ad_free( ad, 1 );
                return LDAP_OTHER;
        }
 
@@ -223,14 +222,13 @@ static int indexer(
        }
 
        ldbm_cache_close( be, db );
-       ad_free( ad, 1 );
        return LDAP_SUCCESS;
 }
 
 static int index_at_values(
        Backend *be,
        AttributeType *type,
-       const char *lang,
+       struct berval *lang,
        struct berval **vals,
        ID id,
        int op,
@@ -267,10 +265,10 @@ static int index_at_values(
        if( lang ) {
                char *dbname = NULL;
                size_t tlen = strlen( type->sat_cname );
-               size_t llen = strlen( lang );
+               size_t llen = lang->bv_len;
                char *lname = ch_malloc( tlen + llen + sizeof(";") );
 
-               sprintf( lname, "%s;%s", type->sat_cname, lang );
+               sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val );
 
                attr_mask( be->be_private, lname, &tmpmask );
 
@@ -309,7 +307,7 @@ int index_values(
        }
 
        (void) index_at_values( be,
-               desc->ad_type, desc->ad_lang,
+               desc->ad_type, &desc->ad_lang,
                vals, id, op,
                &dbname, &mask );
 
index 5ae6bb1959b10875ee0503182b383de11b8bdfbd..18c83efc7c8883a71b232c1a6a050e0fbc94443e 100644 (file)
@@ -357,7 +357,7 @@ add_values(
        int             i;
        Attribute       *a;
 
-       /* char *desc = mod->sm_desc->ad_cname->bv_val; */
+       /* char *desc = mod->sm_desc->ad_cname.bv_val; */
        MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
 
        a = attr_find( e->e_attrs, mod->sm_desc );
@@ -418,7 +418,7 @@ delete_values(
 {
        int             i, j, k, found;
        Attribute       *a;
-       char *desc = mod->sm_desc->ad_cname->bv_val;
+       char *desc = mod->sm_desc->ad_cname.bv_val;
        MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
 
        /* delete the entire attribute */
index 7415c75794b7d3eaa00411700a279aa46255c31c..0d1cd28f71f141760f5acc4bab6f34eb9f96bd37 100644 (file)
@@ -524,7 +524,6 @@ ldbm_back_modrdn(
                                "to attr \"%s\"\n%s%s",
                                new_rdn_types[a_cnt], "", "" );
 #endif
-                       ad_free( desc, 1 );
                        send_ldap_result( conn, op, 
                                LDAP_INSUFFICIENT_ACCESS,
                                NULL, NULL, NULL, NULL );
@@ -601,7 +600,6 @@ ldbm_back_modrdn(
                                        "to attr \"%s\"\n%s%s",
                                        old_rdn_types[d_cnt], "", "" );
 #endif
-                               ad_free( desc, 1 );
                                send_ldap_result( conn, op, 
                                        LDAP_INSUFFICIENT_ACCESS,
                                        NULL, NULL, NULL, NULL );
index f344c793f5b561d4ec70056c0b4d744d0d30e42e..f23c4bb15434dcc4a356aa8eed8744793e712ebb 100644 (file)
@@ -151,21 +151,21 @@ meta_back_add(
                 * of the target directory are used, if available
                 */
 #if 0
-               if ( !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_creatorsName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_createTimestamp->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifiersName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val )
+               if ( !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_creatorsName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_createTimestamp->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifiersName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val )
                ) {
                        continue;
                }
 #endif
                
                mapped = ldap_back_map( &li->targets[ candidate ]->at_map,
-                               a->a_desc->ad_cname->bv_val, 0);
+                               a->a_desc->ad_cname.bv_val, 0);
                if ( mapped == NULL ) {
                        continue;
                }
index f270bed4a192fa9e6487e4a052ec4756c16e8eac..f8c894a21c7280a903988c14b5306b936a89661e 100644 (file)
@@ -138,7 +138,7 @@ meta_back_attribute(
        }
 
        mapped = ldap_back_map( &li->targets[ candidate ]->at_map,
-                       entry_at->ad_cname->bv_val, 0 );
+                       entry_at->ad_cname.bv_val, 0 );
        if ( mapped == NULL )
                return 1;
 
index 12cf49ed602c5fddd18c7b4eb5a987fdff17886f..192a61e7f34f2927b03ad6b3301bd31144983419 100644 (file)
@@ -109,7 +109,7 @@ meta_back_compare(
         */
        for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; ++i, ++lsc ) {
                char *mdn = NULL;
-               char *mapped_attr = ava->aa_desc->ad_cname->bv_val;
+               char *mapped_attr = ava->aa_desc->ad_cname.bv_val;
                char *mapped_value = ava->aa_value->bv_val;
 
                if ( lsc[ 0 ]->candidate != META_CANDIDATE ) {
@@ -166,7 +166,7 @@ meta_back_compare(
                 */
                } else {
                        mapped_attr = ldap_back_map( &li->targets[ i ]->at_map,
-                               ava->aa_desc->ad_cname->bv_val, 0 );
+                               ava->aa_desc->ad_cname.bv_val, 0 );
                        if ( mapped_attr == NULL ) {
                                lsc[ 0 ]->candidate = META_NOT_CANDIDATE;
                                continue;
@@ -188,7 +188,7 @@ meta_back_compare(
                if ( mdn != dn ) {
                        free( mdn );
                }
-               if ( mapped_attr != ava->aa_desc->ad_cname->bv_val ) {
+               if ( mapped_attr != ava->aa_desc->ad_cname.bv_val ) {
                        free( mapped_attr );
                }
                if ( mapped_value != ava->aa_value->bv_val ) {
index 3fd884208e6bb7b49074a8118ed67b615b33b538..56cf41fe8638c74ee6c0b5a0f3d33192fb71acd6 100644 (file)
@@ -105,7 +105,7 @@ meta_back_group(
        char *mop_ndn, *mgr_ndn;
 
        char *group_oc_name = NULL;
-       char *group_at_name = group_at->ad_cname->bv_val;
+       char *group_at_name = group_at->ad_cname.bv_val;
 
        if ( group_oc->soc_names && group_oc->soc_names[ 0 ] ) {
                group_oc_name = group_oc->soc_names[ 0 ];
index dd3ea4c3b2ee31bbc7146b820232ee78129a741a..7fc8b8e6e32b01f87931ed827d095ebf09213768 100644 (file)
@@ -153,20 +153,20 @@ meta_back_modify(
                 * lastmod should always be <off>
                 */
 #if 0
-               if ( !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_creatorsName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_createTimestamp->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifiersName->ad_cname->bv_val )
-                       || !strcasecmp( a->a_desc->ad_cname->bv_val,
-                       slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val ) ) {
+               if ( !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_creatorsName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_createTimestamp->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifiersName->ad_cname.bv_val )
+                       || !strcasecmp( a->a_desc->ad_cname.bv_val,
+                       slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) ) {
                        continue;
                }
 #endif
 
                mapped = ldap_back_map( &li->targets[ candidate ]->at_map,
-                               ml->sml_desc->ad_cname->bv_val, 0 );
+                               ml->sml_desc->ad_cname.bv_val, 0 );
                if ( mapped == NULL ) {
                        continue;
                }
index c033f66d8bb51ea55ede8bd01906bc0b7926b02d..0700f137d76a9284c5d38217aa89da6e6ada3672 100644 (file)
@@ -760,7 +760,6 @@ meta_send_entry(
        while ( ent.e_attrs ) {
                attr = ent.e_attrs;
                ent.e_attrs = attr->a_next;
-               ad_free( attr->a_desc, 1 );
                if ( attr->a_vals != &dummy ) {
                        ber_bvecfree(attr->a_vals);
                }
index 4cc91c042a38874cd705cb328c403d93b75731b3..fe386246d9265ecb4982bc3e3c09d543ff5b4d50 100644 (file)
@@ -115,8 +115,6 @@ passwd_back_search(
 
                        attr_merge( e, desc, vals );
 
-                       ad_free( desc, 1 );
-
                        free(rdn);
                        rdn = NULL;
 
index c7c85f8d68b16df19bcff462cbb5f9fa147ea7c8..6e68ae90f588deef139b48d46790736cd8fd34eb 100644 (file)
@@ -52,7 +52,7 @@ shell_back_compare(
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "%s: %s\n",
-               ava->aa_desc->ad_cname->bv_val,
+               ava->aa_desc->ad_cname.bv_val,
                ava->aa_value->bv_val /* could be binary! */ );
        fclose( wfp );
 
index 0f6d66fd4bc65383fa20108fa60928ce631b2bbf..3eb2e2e1ea6085dd58302ff0b978c9ee1a7c5167 100644 (file)
@@ -55,21 +55,21 @@ shell_back_modify(
 
                switch ( mod->sm_op ) {
                case LDAP_MOD_ADD:
-                       fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname->bv_val );
+                       fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname.bv_val );
                        break;
 
                case LDAP_MOD_DELETE:
-                       fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname->bv_val );
+                       fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname.bv_val );
                        break;
 
                case LDAP_MOD_REPLACE:
-                       fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname->bv_val );
+                       fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname.bv_val );
                        break;
                }
 
                if( mod->sm_bvalues != NULL ) {
                        for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
-                               fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname->bv_val,
+                               fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val,
                                        mod->sm_bvalues[i]->bv_val /* binary! */ );
                        }
                }
index fa5bc70b6e616fdd91261dc2ac863d06a2f526cb..bf4f0bb1ede308f6beb1720228a9b7a53775b092 100644 (file)
@@ -68,11 +68,11 @@ int backsql_modify(BackendDB *be,Connection *conn,Operation *op,
  for(ml=modlist;ml!=NULL;ml=ml->sml_next)
  {
   c_mod=&ml->sml_mod;
-  Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute '%s'\n",c_mod->sm_desc->ad_cname->bv_val,0,0);
-  at=backsql_at_with_name(oc,c_mod->sm_desc->ad_cname->bv_val);
+  Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute '%s'\n",c_mod->sm_desc->ad_cname.bv_val,0,0);
+  at=backsql_at_with_name(oc,c_mod->sm_desc->ad_cname.bv_val);
   if (at==NULL)
   {
-   Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute provided is not registered in this objectclass ('%s')\n",c_mod->sm_desc->ad_cname->bv_val,0,0);
+   Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute provided is not registered in this objectclass ('%s')\n",c_mod->sm_desc->ad_cname.bv_val,0,0);
    continue;
   }
   
@@ -371,7 +371,7 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e)
  for(at=e->e_attrs;at!=NULL;at=at->a_next)
  {
   /*Debug(LDAP_DEBUG_TRACE,"backsql_add(): scanning entry -- %s\n",at->a_type,0,0);*/
-  if (!strcasecmp(at->a_desc->ad_cname->bv_val,"objectclass"))
+  if (!strcasecmp(at->a_desc->ad_cname.bv_val,"objectclass"))
   {
    oc=backsql_oc_with_name(bi,at->a_vals[0]->bv_val);
    break;
@@ -417,16 +417,16 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e)
 
  for(at=e->e_attrs;at!=NULL;at=at->a_next)
  {
-  at_rec=backsql_at_with_name(oc,at->a_desc->ad_cname->bv_val); 
+  at_rec=backsql_at_with_name(oc,at->a_desc->ad_cname.bv_val); 
   
   if (at_rec==NULL)
   {
-   Debug(LDAP_DEBUG_TRACE,"backsql_add(): attribute provided is not registered in this objectclass ('%s')\n",at->a_desc->ad_cname->bv_val,0,0);
+   Debug(LDAP_DEBUG_TRACE,"backsql_add(): attribute provided is not registered in this objectclass ('%s')\n",at->a_desc->ad_cname.bv_val,0,0);
    continue;
   }
   if (at_rec->add_proc==NULL)
   {
-   Debug(LDAP_DEBUG_TRACE,"backsql_add(): add procedure is not defined for this attribute ('%s')\n",at->a_desc->ad_cname->bv_val,0,0);
+   Debug(LDAP_DEBUG_TRACE,"backsql_add(): add procedure is not defined for this attribute ('%s')\n",at->a_desc->ad_cname.bv_val,0,0);
    continue;
   }
   
index ba3bfc03ca266bcbfa4f487f0289f1750821f96d..5853597451e67dbc8a9a8a9f70fba88c24496849 100644 (file)
@@ -113,7 +113,7 @@ int backsql_process_filter_list(backsql_srch_info *bsi,Filter *f,int op)
 int backsql_process_sub_filter(backsql_srch_info *bsi,Filter *f)
 {
  int i;
- backsql_at_map_rec *at=backsql_at_with_name(bsi->oc,f->f_sub_desc->ad_cname->bv_val);
+ backsql_at_map_rec *at=backsql_at_with_name(bsi->oc,f->f_sub_desc->ad_cname.bv_val);
  
  if (!f)
   return 0;
@@ -208,10 +208,10 @@ int backsql_process_filter(backsql_srch_info *bsi,Filter *f)
                        done=1;
                        break;
   case LDAP_FILTER_PRESENT:
-                       at_name=f->f_desc->ad_cname->bv_val;
+                       at_name=f->f_desc->ad_cname.bv_val;
                        break;
   default:
-                        at_name=f->f_av_desc->ad_cname->bv_val;
+                        at_name=f->f_av_desc->ad_cname.bv_val;
                        break;
  }
 
index 3de62bae8069fbd3612c9994eac62119f05f858b..fcb1254db271e5a4bfb14de6fe4c0faddee61890 100644 (file)
@@ -93,7 +93,6 @@ int backsql_entry_addattr(Entry *e,char *at_name,char *at_val,unsigned int at_va
   }
   
  rc = attr_merge(e,ad,add_val);
- ad_free( ad, 1 );
 
  if( rc != 0 )
   {
index ca5fe460744799cdad3d3937de259ec95693ced8..31a031963d0cf1641019ddc94ca0f6f6ebc97c22 100644 (file)
@@ -1011,7 +1011,7 @@ Attribute *backend_operational(
 
 #ifdef SLAPD_SCHEMA_DN
        a = ch_malloc( sizeof( Attribute ) );
-       a->a_desc = ad_dup( slap_schema.si_ad_subschemaSubentry );
+       a->a_desc = slap_schema.si_ad_subschemaSubentry;
 
        /* Should be backend specific */
        a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
index 886ce341dc978a4857170c500c0fe3142c857669..8196988daf7214ca0265932b1635e48001f929ff 100644 (file)
@@ -192,15 +192,15 @@ do_compare(
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                   "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                  conn->c_connid, dn, ava.aa_desc->ad_cname->bv_val,
+                  conn->c_connid, dn, ava.aa_desc->ad_cname.bv_val,
                   ava.aa_value->bv_val ));
 #else
        Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-           dn, ava.aa_desc->ad_cname->bv_val, ava.aa_value->bv_val );
+           dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-           op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname->bv_val, 0 );
+           op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname.bv_val, 0 );
 
 
        /* deref suffix alias if appropriate */
@@ -218,9 +218,6 @@ cleanup:
        free( ndn );
        free( desc.bv_val );
        free( value.bv_val );
-       if( ava.aa_desc != NULL ) {
-               ad_free( ava.aa_desc, 1 );
-       }
 
        return rc;
 }
index 2c9ce52b6f07200e56d8e004f9e044ace37ae87c..0bea4e125c00da49dfc575af25cdde8fddcf29ce 100644 (file)
@@ -215,8 +215,6 @@ str2entry( char *s )
 
                rc = attr_merge( e, ad, vals );
 
-               ad_free( ad, 1 );
-
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
@@ -307,10 +305,10 @@ entry2str(
                /* put "<type>:[:] <value>" line for each value */
                for ( i = 0; a->a_vals[i] != NULL; i++ ) {
                        bv = a->a_vals[i];
-                       tmplen = a->a_desc->ad_cname->bv_len;
+                       tmplen = a->a_desc->ad_cname.bv_len;
                        MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
                        ldif_sput( (char **) &ecur, LDIF_PUT_VALUE,
-                               a->a_desc->ad_cname->bv_val,
+                               a->a_desc->ad_cname.bv_val,
                            bv->bv_val, bv->bv_len );
                }
        }
@@ -501,21 +499,21 @@ int entry_decode( struct berval *bv, Entry **entry )
                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                  "entry_decode: str2ad(%s): %s\n", type, text ));
+                                  "entry_decode: str2ad(%s): %s\n", type->bv_val, text ));
 #else
                        Debug( LDAP_DEBUG_TRACE,
-                               "<= entry_decode: str2ad(%s): %s\n", type, text, 0 );
+                               "<= entry_decode: str2ad(%s): %s\n", type->bv_val, text, 0 );
 #endif
                        rc = slap_bv2undef_ad( type, &ad, &text );
 
                        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                          "entry_decode:  str2undef_ad(%s): %s\n", type, text));
+                                          "entry_decode:  str2undef_ad(%s): %s\n", type->bv_val, text));
 #else
                                Debug( LDAP_DEBUG_ANY,
                                        "<= entry_decode: str2undef_ad(%s): %s\n",
-                                               type, text, 0 );
+                                               type->bv_val, text, 0 );
 #endif
                                ber_bvfree( type );
                                ber_bvecfree( vals );
@@ -525,7 +523,6 @@ int entry_decode( struct berval *bv, Entry **entry )
                }
 
                rc = attr_merge( e, ad, vals );
-               ad_free( ad, 1 );
 
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
@@ -591,7 +588,7 @@ int entry_encode(
 
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
                rc = ber_printf( ber, "{O{V}}",
-                       a->a_desc->ad_cname,
+                       &a->a_desc->ad_cname,
                        a->a_vals );
                if( rc < 0 ) {
                        goto done;
index 70aa4b5e28389ab03a2a44e277c05a6a44f4d762..b06f3459357c70dd704ffdb7666e7352e4e930c2 100644 (file)
@@ -118,11 +118,11 @@ get_filter(
                filter_escape_value( f->f_av_value, &escaped );
 
                *fstr = ch_malloc( sizeof("(=)")
-                       + f->f_av_desc->ad_cname->bv_len
+                       + f->f_av_desc->ad_cname.bv_len
                        + escaped.bv_len );
 
                sprintf( *fstr, "(%s=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
 
                ber_memfree( escaped.bv_val );
@@ -153,11 +153,11 @@ get_filter(
                filter_escape_value( f->f_av_value, &escaped );
 
                *fstr = ch_malloc( sizeof("(>=)")
-                       + f->f_av_desc->ad_cname->bv_len
+                       + f->f_av_desc->ad_cname.bv_len
                        + escaped.bv_len );
 
                sprintf( *fstr, "(%s>=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
 
                ber_memfree( escaped.bv_val );
@@ -179,11 +179,11 @@ get_filter(
                filter_escape_value( f->f_av_value, &escaped );
 
                *fstr = ch_malloc( sizeof("(<=)")
-                       + f->f_av_desc->ad_cname->bv_len
+                       + f->f_av_desc->ad_cname.bv_len
                        + escaped.bv_len );
 
                sprintf( *fstr, "(%s<=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
 
                ber_memfree( escaped.bv_val );
@@ -215,9 +215,9 @@ get_filter(
                ch_free( type.bv_val );
 
                *fstr = ch_malloc( sizeof("(=*)")
-                       + f->f_desc->ad_cname->bv_len );
+                       + f->f_desc->ad_cname.bv_len );
                sprintf( *fstr, "(%s=*)",
-                       f->f_desc->ad_cname->bv_val );
+                       f->f_desc->ad_cname.bv_val );
 
                } break;
 
@@ -236,11 +236,11 @@ get_filter(
                filter_escape_value( f->f_av_value, &escaped );
 
                *fstr = ch_malloc( sizeof("(~=)")
-                       + f->f_av_desc->ad_cname->bv_len
+                       + f->f_av_desc->ad_cname.bv_len
                        + escaped.bv_len );
 
                sprintf( *fstr, "(%s~=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
 
                ber_memfree( escaped.bv_val );
@@ -316,12 +316,12 @@ get_filter(
                filter_escape_value( f->f_mr_value, &escaped );
 
                *fstr = ch_malloc( sizeof("(:dn::=)")
-                       + (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_len : 0)
+                       + (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_len : 0)
                        + (f->f_mr_rule_text ? strlen(f->f_mr_rule_text) : 0)
                        + escaped.bv_len );
 
                sprintf( *fstr, "(%s%s%s%s:=%s)",
-                        (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_val : ""),
+                        (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_val : ""),
                         (f->f_mr_dnattrs ? ":dn" : ""),
                         (f->f_mr_rule_text ? ":" : ""),
                         (f->f_mr_rule_text ? f->f_mr_rule_text : ""),
@@ -474,8 +474,8 @@ get_substring_filter(
 
        if( fstr ) {
                *fstr = ch_malloc( sizeof("(=" /*)*/) +
-                       f->f_sub_desc->ad_cname->bv_len );
-               sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname->bv_val );
+                       f->f_sub_desc->ad_cname.bv_len );
+               sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname.bv_val );
        }
 
        for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
@@ -646,7 +646,6 @@ return_error:
                                *fstr = NULL;
                        }
 
-                       ad_free( f->f_sub_desc, 1 );
                        ber_bvfree( f->f_sub_initial );
                        ber_bvecfree( f->f_sub_any );
                        ber_bvfree( f->f_sub_final );
@@ -683,7 +682,6 @@ filter_free( Filter *f )
 
        switch ( f->f_choice ) {
        case LDAP_FILTER_PRESENT:
-               ad_free( f->f_desc, 1 );
                break;
 
        case LDAP_FILTER_EQUALITY:
@@ -694,7 +692,6 @@ filter_free( Filter *f )
                break;
 
        case LDAP_FILTER_SUBSTRINGS:
-               ad_free( f->f_sub_desc, 1 );
                if ( f->f_sub_initial != NULL ) {
                        ber_bvfree( f->f_sub_initial );
                }
@@ -747,7 +744,7 @@ filter_print( Filter *f )
        case LDAP_FILTER_EQUALITY:
                filter_escape_value( f->f_av_value, &escaped );
                fprintf( stderr, "(%s=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
                ber_memfree( escaped.bv_val );
                break;
@@ -755,7 +752,7 @@ filter_print( Filter *f )
        case LDAP_FILTER_GE:
                filter_escape_value( f->f_av_value, &escaped );
                fprintf( stderr, "(%s>=%s)",
-                       f->f_av_desc->ad_cname->bv_val,
+                       f->f_av_desc->ad_cname.bv_val,
                    escaped.bv_val );
                ber_memfree( escaped.bv_val );
                break;
@@ -763,7 +760,7 @@ filter_print( Filter *f )
        case LDAP_FILTER_LE:
                filter_escape_value( f->f_av_value, &escaped );
                fprintf( stderr, "(%s<=%s)",
-                       f->f_ava->aa_desc->ad_cname->bv_val,
+                       f->f_ava->aa_desc->ad_cname.bv_val,
                    escaped.bv_val );
                ber_memfree( escaped.bv_val );
                break;
@@ -771,14 +768,14 @@ filter_print( Filter *f )
        case LDAP_FILTER_APPROX:
                filter_escape_value( f->f_av_value, &escaped );
                fprintf( stderr, "(%s~=%s)",
-                       f->f_ava->aa_desc->ad_cname->bv_val,
+                       f->f_ava->aa_desc->ad_cname.bv_val,
                    escaped.bv_val );
                ber_memfree( escaped.bv_val );
                break;
 
        case LDAP_FILTER_SUBSTRINGS:
                fprintf( stderr, "(%s=" /*)*/,
-                       f->f_sub_desc->ad_cname->bv_val );
+                       f->f_sub_desc->ad_cname.bv_val );
                if ( f->f_sub_initial != NULL ) {
                        filter_escape_value( f->f_sub_initial, &escaped );
                        fprintf( stderr, "%s",
@@ -804,7 +801,7 @@ filter_print( Filter *f )
 
        case LDAP_FILTER_PRESENT:
                fprintf( stderr, "(%s=*)",
-                       f->f_desc->ad_cname->bv_val );
+                       f->f_desc->ad_cname.bv_val );
                break;
 
        case LDAP_FILTER_AND:
index ebdb637dabca3e6dbbfc9524568bd8d21af01f9d..cfd38d77a2db55eb2bf2e3ef101e9b1a99ac1070 100644 (file)
@@ -43,6 +43,7 @@ ldap_pvt_thread_mutex_t       gmtime_mutex;
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
 ldap_pvt_thread_mutex_t        passwd_mutex;
 #endif
+ldap_pvt_thread_mutex_t ad_mutex;
 
 int                            num_conns;
 long                   num_ops_initiated;
@@ -117,6 +118,7 @@ slap_init( int mode, const char *name )
                        ldap_pvt_thread_mutex_init( &num_sent_mutex );
 
                        ldap_pvt_thread_mutex_init( &gmtime_mutex );
+                       ldap_pvt_thread_mutex_init( &ad_mutex );
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
                        ldap_pvt_thread_mutex_init( &passwd_mutex );
 #endif
index 2089bff88341b9d8b76dfd5964e3547a11b8a072..c3e21d1b8e9cd859ae17c083928b13f698fdd0bf 100644 (file)
@@ -541,7 +541,7 @@ int slap_mods_opattrs(
        if( op->o_tag == LDAP_REQ_ADD ) {
                mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
                mod->sml_op = mop;
-               mod->sml_desc = ad_dup( slap_schema.si_ad_creatorsName );
+               mod->sml_desc = slap_schema.si_ad_creatorsName;
                mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
                mod->sml_bvalues[0] = ber_bvdup( &name );
                mod->sml_bvalues[1] = NULL;
@@ -551,7 +551,7 @@ int slap_mods_opattrs(
 
                mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
                mod->sml_op = mop;
-               mod->sml_desc = ad_dup( slap_schema.si_ad_createTimestamp );
+               mod->sml_desc = slap_schema.si_ad_createTimestamp;
                mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
                mod->sml_bvalues[0] = ber_bvdup( &timestamp );
                mod->sml_bvalues[1] = NULL;
@@ -561,7 +561,7 @@ int slap_mods_opattrs(
 
        mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
        mod->sml_op = mop;
-       mod->sml_desc = ad_dup( slap_schema.si_ad_modifiersName );
+       mod->sml_desc = slap_schema.si_ad_modifiersName;
        mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
        mod->sml_bvalues[0] = ber_bvdup( &name );
        mod->sml_bvalues[1] = NULL;
@@ -570,7 +570,7 @@ int slap_mods_opattrs(
 
        mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
        mod->sml_op = mop;
-       mod->sml_desc = ad_dup( slap_schema.si_ad_modifyTimestamp );
+       mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
        mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
        mod->sml_bvalues[0] = ber_bvdup( &timestamp );
        mod->sml_bvalues[1] = NULL;
index 7b59cc5e1ee7d8ae803b65e74bb72d0e49bd05df..328cfc728732b5227a8a7aa360a6d393e4c7660c 100644 (file)
@@ -24,8 +24,6 @@ slap_mod_free(
        int                             freeit
 )
 {
-       ad_free( mod->sm_desc, 1 );
-
        if ( mod->sm_bvalues != NULL )
                ber_bvecfree( mod->sm_bvalues );
 
index fe883e6e54636c53b65db5229a98b0cf11c4737b..1e66f91f6d6b10f4072ee3a46847fc07c7a0384d 100644 (file)
@@ -21,7 +21,6 @@ mra_free(
     int        freeit
 )
 {
-       ad_free( mra->ma_desc, 1 );
        ch_free( mra->ma_rule_text );
        ber_bvfree( mra->ma_value );
        if ( freeit ) {
index e8bf36c2f8fd6a339ca12f6c5e7e6f80162dfc66..05acf2ded56cb0bdd30cec16531189c677fd1342 100644 (file)
@@ -28,12 +28,8 @@ LDAP_SLAPD_F (int) slap_bv2ad LDAP_P((
 LDAP_SLAPD_F (AttributeDescription *) ad_dup LDAP_P((
        AttributeDescription *desc ));
 
-LDAP_SLAPD_F (void) ad_free LDAP_P((
-       AttributeDescription *desc,
-       int freeit ));
-
 #define ad_cmp(l,r)    ( strcasecmp( \
-       (l)->ad_cname->bv_val, (r)->ad_cname->bv_val ))
+       (l)->ad_cname.bv_val, (r)->ad_cname.bv_val ))
 
 LDAP_SLAPD_F (int) is_ad_subtype LDAP_P((
        AttributeDescription *sub,
index 2dc8344f8ef39468b8ae34473c2bc7444f75d6d6..e309d942cfc6cf958485eee50b1c2eb9717b0661 100644 (file)
@@ -136,7 +136,7 @@ replog(
                ml = change;
                for ( ; ml != NULL; ml = ml->sml_next ) {
                        char *type;
-                       type = ml->sml_desc->ad_cname->bv_val;
+                       type = ml->sml_desc->ad_cname.bv_val;
                        switch ( ml->sml_op ) {
                        case LDAP_MOD_ADD:
                                fprintf( fp, "add: %s\n", type );
index f869f86c91d2f0eddc4f8817f1c31ba1627d84d3..0248a659aca0330a079ad52cb70ec6e898fe3625 100644 (file)
@@ -810,7 +810,7 @@ send_search_entry(
 
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
                AttributeDescription *desc = a->a_desc;
-               char *type = desc->ad_cname->bv_val;
+               char *type = desc->ad_cname.bv_val;
 
                if ( attrs == NULL ) {
                        /* all addrs request, skip operational attributes */
@@ -836,10 +836,10 @@ send_search_entry(
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
                                   "send_search_entry: conn %d  access to attribute %s not allowed\n",
-                                  op->o_connid, desc->ad_cname->bv_val ));
+                                  op->o_connid, desc->ad_cname.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
-                           desc->ad_cname->bv_val, 0, 0 );
+                           desc->ad_cname.bv_val, 0, 0 );
 #endif
 
                        continue;
@@ -868,11 +868,11 @@ send_search_entry(
 #ifdef NEW_LOGGING
                                        LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
                                                   "send_search_entry: conn %d  access to attribute %s, value %d not allowed\n",
-                                                  op->o_connid, desc->ad_cname->bv_val, i ));
+                                                  op->o_connid, desc->ad_cname.bv_val, i ));
 #else
                                        Debug( LDAP_DEBUG_ACL,
                                                "acl: access to attribute %s, value %d not allowed\n",
-                                       desc->ad_cname->bv_val, i, 0 );
+                                       desc->ad_cname.bv_val, i, 0 );
 #endif
 
                                        continue;
@@ -943,16 +943,16 @@ send_search_entry(
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
                                   "send_search_entry: conn %s  access to attribute %s not allowed\n",
-                                  op->o_connid, desc->ad_cname->bv_val ));
+                                  op->o_connid, desc->ad_cname.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
-                           desc->ad_cname->bv_val, 0, 0 );
+                           desc->ad_cname.bv_val, 0, 0 );
 #endif
 
                        continue;
                }
 
-               rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname->bv_val );
+               rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname.bv_val );
                if ( rc == -1 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
@@ -977,11 +977,11 @@ send_search_entry(
 #ifdef NEW_LOGGING
                                        LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
                                                   "send_search_entry: conn %d access to %s, value %d not allowed\n",
-                                                  op->o_connid, desc->ad_cname->bv_val, i ));
+                                                  op->o_connid, desc->ad_cname.bv_val, i ));
 #else
                                        Debug( LDAP_DEBUG_ACL,
                                                "acl: access to attribute %s, value %d not allowed\n",
-                                       desc->ad_cname->bv_val, i, 0 );
+                                       desc->ad_cname.bv_val, i, 0 );
 #endif
 
                                        continue;
index fcc6c05ce9940bfdeecede469c7453bdc4925e59..5a8b689be537898e4c4309767a7ad24407fc3808 100644 (file)
@@ -567,7 +567,6 @@ slap_sasl_check_authz(char *searchDN, char *assertDN, char *attr, char *authc)
 
 COMPLETE:
        if( vals ) ber_bvecfree( vals );
-       if( ad ) ad_free( ad, 1 );
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY,
index 6f7d993dd6df957bb0a6612c16438816953b08df..4fcc00fbf9a1941bb9efbf39d1f9a569c7f3b3a2 100644 (file)
@@ -48,7 +48,7 @@ entry_schema_check(
                if( is_at_single_value( a->a_desc->ad_type ) &&
                        a->a_vals[1] != NULL )
                {
-                       char *type = a->a_desc->ad_cname->bv_val;
+                       char *type = a->a_desc->ad_cname.bv_val;
 
                        snprintf( textbuf, textlen, 
                                "attribute '%s' cannot have multiple values",
@@ -139,7 +139,7 @@ entry_schema_check(
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
                int ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals );
                if ( ret != LDAP_SUCCESS ) {
-                       char *type = a->a_desc->ad_cname->bv_val;
+                       char *type = a->a_desc->ad_cname.bv_val;
 
                        snprintf( textbuf, textlen, 
                                "attribute '%s' not allowed",
index a8c770a03facc9990f57a7561155c88663eae33c..cef3d3e3d9a0908f8cf8f178c3911fbeee0046e7 100644 (file)
@@ -364,6 +364,8 @@ typedef struct slap_matching_rule {
 #define smr_extensions         smr_mrule.mr_extensions
 } MatchingRule;
 
+struct slap_attr_desc;
+
 typedef struct slap_attribute_type {
        char                                    *sat_cname;
        LDAPAttributeType               sat_atype;
@@ -374,6 +376,7 @@ typedef struct slap_attribute_type {
        MatchingRule                    *sat_ordering;
        MatchingRule                    *sat_substr;
        Syntax                          *sat_syntax;
+       struct slap_attr_desc           *sat_ad;
        struct slap_attribute_type      *sat_next;
 #define sat_oid                        sat_atype.at_oid
 #define sat_names              sat_atype.at_names
@@ -419,15 +422,16 @@ typedef struct slap_object_class {
  * represents a recognized attribute description ( type + options )
  */
 typedef struct slap_attr_desc {
-       struct berval *ad_cname;        /* canonical name, must be specified */
+       struct slap_attr_desc *ad_next;
        AttributeType *ad_type;         /* attribute type, must be specified */
-       char *ad_lang;                          /* NULL if no language tags */
+       struct berval ad_cname;         /* canonical name, must be specified */
+       struct berval ad_lang;          /* empty if no language tags */
        unsigned ad_flags;
 #define SLAP_DESC_NONE         0x0U
 #define SLAP_DESC_BINARY       0x1U
 } AttributeDescription;
 
-#define slap_ad_is_lang(ad)            ( (ad)->ad_lang != NULL )
+#define slap_ad_is_lang(ad)            ( (ad)->ad_lang.bv_len != 0 )
 #define slap_ad_is_binary(ad)  ( (int)((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 )
 
 /*