Commit 5f8058f9 authored by Howard Chu's avatar Howard Chu
Browse files

Added schema_destroy() et al to free schema structures on shutdown

parent 76243a27
......@@ -37,6 +37,16 @@ static int ad_keystring(
return 0;
}
void ad_destroy( void *in )
{
AttributeDescription *ad = in, *n;
for (;ad;ad = n) {
n = ad->ad_next;
ldap_memfree(ad);
}
}
int slap_str2ad(
const char *str,
AttributeDescription **ad,
......
......@@ -171,6 +171,20 @@ at_find_in_list(
return -1;
}
void
at_destroy( void )
{
AttributeType *a, *n;
avl_free(attr_index, ldap_memfree);
for (a=attr_list; a; a=n) {
n = a->sat_next;
ldap_memfree(a->sat_subtypes);
ad_destroy(a->sat_ad);
ldap_attributetype_free((LDAPAttributeType *)a);
}
}
static int
at_insert(
AttributeType *sat,
......@@ -207,13 +221,12 @@ at_insert(
while ( *names ) {
air = (struct aindexrec *)
ch_calloc( 1, sizeof(struct aindexrec) );
air->air_name = ch_strdup(*names);
air->air_name = *names;
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
(AVL_CMP) attr_index_cmp,
(AVL_DUP) avl_dup_error ) ) {
*err = *names;
ldap_memfree(air->air_name);
ldap_memfree(air);
return SLAP_SCHERR_DUP_ATTR;
}
......
......@@ -542,6 +542,8 @@ stop:
#endif
slapd_daemon_destroy();
schema_destroy();
#ifdef HAVE_TLS
ldap_pvt_tls_destroy();
#endif
......
......@@ -55,6 +55,18 @@ mr_find( const char *mrname )
return( NULL );
}
void
mr_destroy( void )
{
MatchingRule *m, *n;
avl_free(mr_index, ldap_memfree);
for (m=mr_list; m; m=n) {
n = m->smr_next;
ldap_matchingrule_free((LDAPMatchingRule *)m);
}
}
static int
mr_insert(
MatchingRule *smr,
......@@ -90,7 +102,7 @@ mr_insert(
while ( *names ) {
mir = (struct mindexrec *)
ch_calloc( 1, sizeof(struct mindexrec) );
mir->mir_name = ch_strdup(*names);
mir->mir_name = *names;
mir->mir_mr = smr;
if ( avl_insert( &mr_index, (caddr_t) mir,
(AVL_CMP) mr_index_cmp,
......
......@@ -279,6 +279,22 @@ oc_add_sups(
return 0;
}
void
oc_destroy( void )
{
ObjectClass *o, *n;
avl_free(oc_index, ldap_memfree);
for (o=oc_list; o; o=n)
{
n = o->soc_next;
ldap_memfree(o->soc_sups);
ldap_memfree(o->soc_required);
ldap_memfree(o->soc_allowed);
ldap_objectclass_free((LDAPObjectClass *)o);
}
}
static int
oc_insert(
ObjectClass *soc,
......@@ -309,7 +325,6 @@ oc_insert(
(AVL_DUP) avl_dup_error ) )
{
*err = soc->soc_oid;
ldap_memfree(oir->oir_name);
ldap_memfree(oir);
return SLAP_SCHERR_DUP_CLASS;
}
......@@ -322,7 +337,7 @@ oc_insert(
while ( *names ) {
oir = (struct oindexrec *)
ch_calloc( 1, sizeof(struct oindexrec) );
oir->oir_name = ch_strdup(*names);
oir->oir_name = *names;
oir->oir_oc = soc;
assert( oir->oir_name );
......@@ -333,7 +348,6 @@ oc_insert(
(AVL_DUP) avl_dup_error ) )
{
*err = *names;
ldap_memfree(oir->oir_name);
ldap_memfree(oir);
return SLAP_SCHERR_DUP_CLASS;
}
......
......@@ -620,6 +620,13 @@ LDAP_SLAPD_F (int) syn_schema_info( Entry *e );
* schema.c
*/
LDAP_SLAPD_F (void) oc_destroy LDAP_P(( void ));
LDAP_SLAPD_F (void) at_destroy LDAP_P(( void ));
LDAP_SLAPD_F (void) ad_destroy LDAP_P(( void * ));
LDAP_SLAPD_F (void) mr_destroy LDAP_P(( void ));
LDAP_SLAPD_F (void) syn_destroy LDAP_P(( void ));
LDAP_SLAPD_F (void) schema_destroy LDAP_P(( void ));
LDAP_SLAPD_F (ObjectClass *) oc_find LDAP_P((
const char *ocname));
......
......@@ -4726,3 +4726,12 @@ schema_init( void )
schema_init_done = 1;
return LDAP_SUCCESS;
}
void
schema_destroy( void )
{
oc_destroy();
at_destroy();
mr_destroy();
syn_destroy();
}
......@@ -369,8 +369,8 @@ typedef struct slap_matching_rule {
struct slap_attr_desc;
typedef struct slap_attribute_type {
char *sat_cname;
LDAPAttributeType sat_atype;
char *sat_cname;
struct slap_attribute_type *sat_sup;
struct slap_attribute_type **sat_subtypes;
MatchingRule *sat_equality;
......
......@@ -66,6 +66,18 @@ syn_find_desc( const char *syndesc, int *len )
return( NULL );
}
void
syn_destroy( void )
{
Syntax *s, *n;
avl_free(syn_index, ldap_memfree);
for (s=syn_list; s; s=n) {
n = s->ssyn_next;
ldap_syntax_free((LDAPSyntax *)s);
}
}
static int
syn_insert(
Syntax *ssyn,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment