void
syn_destroy( void )
{
- Syntax *s;
-
- avl_free(syn_index, ldap_memfree);
- while( !LDAP_SLIST_EMPTY(&syn_list) ) {
- s = LDAP_SLIST_FIRST(&syn_list);
- LDAP_SLIST_REMOVE_HEAD(&syn_list, ssyn_next);
- ldap_syntax_free((LDAPSyntax *)s);
+ Syntax *s;
+
+ avl_free( syn_index, ldap_memfree );
+ while( !LDAP_SLIST_EMPTY( &syn_list ) ) {
+ s = LDAP_SLIST_FIRST( &syn_list );
+ LDAP_SLIST_REMOVE_HEAD( &syn_list, ssyn_next );
+ if ( s->ssyn_sups ) {
+ SLAP_FREE( s->ssyn_sups );
+ }
+ ldap_syntax_free( (LDAPSyntax *)s );
}
}
int code = 0;
ssyn = (Syntax *) SLAP_CALLOC( 1, sizeof(Syntax) );
- if( ssyn == NULL ) {
+ if ( ssyn == NULL ) {
Debug( LDAP_DEBUG_ANY, "SLAP_CALLOC Error\n", 0, 0, 0 );
- return LDAP_OTHER;
+ return SLAP_SCHERR_OUTOFMEM;
}
AC_MEMCPY( &ssyn->ssyn_syn, syn, sizeof(LDAPSyntax) );
ssyn->ssyn_validate = def->sd_validate;
ssyn->ssyn_pretty = def->sd_pretty;
+ ssyn->ssyn_sups = NULL;
+
#ifdef SLAPD_BINARY_CONVERSION
ssyn->ssyn_ber2str = def->sd_ber2str;
ssyn->ssyn_str2ber = def->sd_str2ber;
for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ )
;
- ssyn->ssyn_sups = (Syntax **)SLAP_CALLOC( cnt + 1,
+ ssyn->ssyn_sups = (Syntax **)ch_calloc( cnt + 1,
sizeof(Syntax) );
for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ ) {
if ( code == 0 ) {
code = syn_insert( ssyn, err );
+
+ } else if ( ssyn != NULL ) {
+ if ( ssyn->ssyn_sups != NULL ) {
+ ch_free( ssyn->ssyn_sups );
+ }
+ SLAP_FREE( ssyn );
}
return code;