]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/at.c
ITS#4040 move initialization
[openldap] / servers / slapd / at.c
index 423a6d38e109315438da619f2063501207754823..59bdb98142a23cf8882be565ef94941c41e9198a 100644 (file)
@@ -214,7 +214,31 @@ at_destroy( void )
                a = LDAP_STAILQ_FIRST(&attr_list);
                LDAP_STAILQ_REMOVE_HEAD(&attr_list, sat_next);
 
-               if (a->sat_subtypes) ldap_memfree(a->sat_subtypes);
+               if ( a->sat_equality ) {
+                       MatchingRule    *mr;
+
+                       mr = mr_find( a->sat_equality->smr_oid );
+                       assert( mr != NULL );
+                       if ( mr != a->sat_equality ) {
+                               ch_free( a->sat_equality );
+                               a->sat_equality = NULL;
+                       }
+               }
+
+               assert( a->sat_syntax != NULL );
+               if ( a->sat_syntax != NULL ) {
+                       Syntax          *syn;
+
+                       syn = syn_find( a->sat_syntax->ssyn_oid );
+                       assert( syn != NULL );
+                       if ( syn != a->sat_syntax ) {
+                               ch_free( a->sat_syntax );
+                               a->sat_syntax = NULL;
+                       }
+               }
+
+               if ( a->sat_oidmacro ) ldap_memfree( a->sat_oidmacro );
+               if ( a->sat_subtypes ) ldap_memfree( a->sat_subtypes );
                ad_destroy(a->sat_ad);
                ldap_pvt_thread_mutex_destroy(&a->sat_ad_mutex);
                ldap_attributetype_free((LDAPAttributeType *)a);
@@ -223,6 +247,10 @@ at_destroy( void )
        if ( slap_schema.si_at_undefined ) {
                ad_destroy(slap_schema.si_at_undefined->sat_ad);
        }
+
+       if ( slap_schema.si_at_proxied ) {
+               ad_destroy(slap_schema.si_at_proxied->sat_ad);
+       }
 }
 
 int
@@ -376,6 +404,18 @@ at_insert(
                }
        }
 
+       if ( sat->sat_oid ) {
+               slap_ad_undef_promote( sat->sat_oid, sat );
+       }
+
+       names = sat->sat_names;
+       if ( names ) {
+               while ( *names ) {
+                       slap_ad_undef_promote( *names, sat );
+                       names++;
+               }
+       }
+
        LDAP_STAILQ_INSERT_TAIL( &attr_list, sat, sat_next );
 
        return 0;
@@ -383,10 +423,10 @@ at_insert(
 
 int
 at_add(
-    LDAPAttributeType  *at,
-       int                             user,
-       AttributeType   **rsat,
-    const char         **err )
+       LDAPAttributeType       *at,
+       int                     user,
+       AttributeType           **rsat,
+       const char              **err )
 {
        AttributeType   *sat;
        MatchingRule    *mr;
@@ -706,6 +746,11 @@ error_return:;
                        ch_free( sat );
                }
 
+               if ( oidm ) {
+                       SLAP_FREE( at->at_oid );
+                       at->at_oid = oidm;
+               }
+
        } else if ( rsat ) {
                *rsat = sat;
        }