]> git.sur5r.net Git - openldap/commitdiff
Minor cleanup
authorHoward Chu <hyc@openldap.org>
Mon, 31 Dec 2001 06:44:36 +0000 (06:44 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 31 Dec 2001 06:44:36 +0000 (06:44 +0000)
libraries/libldap/schema.c
servers/slapd/at.c
servers/slapd/back-ldbm/bind.c
servers/slapd/back-ldbm/referral.c
servers/slapd/back-ldbm/search.c
servers/slapd/backend.c
servers/slapd/entry.c
servers/slapd/filter.c
servers/slapd/modrdn.c
servers/slapd/oc.c

index 6f7020846923a8ca676eca4f4daa811911f7b24e..5e33d6e1ce8532cfd863a76bd90ff0257c37c998 100644 (file)
@@ -840,7 +840,7 @@ parse_numericoid(const char **sp, int *code, const int flags)
                }
        }
        if (flags & LDAP_SCHEMA_SKIP) {
-               res = start;
+               res = (char *)start;
        } else {
                res = LDAP_MALLOC(len+1);
                if (!res) {
@@ -1140,8 +1140,8 @@ void
 ldap_syntax_free( LDAPSyntax * syn )
 {
        LDAP_FREE(syn->syn_oid);
-       LDAP_VFREE(syn->syn_names);
-       LDAP_FREE(syn->syn_desc);
+       if (syn->syn_names) LDAP_VFREE(syn->syn_names);
+       if (syn->syn_desc) LDAP_FREE(syn->syn_desc);
        free_extensions(syn->syn_extensions);
        LDAP_FREE(syn);
 }
@@ -1281,9 +1281,9 @@ void
 ldap_matchingrule_free( LDAPMatchingRule * mr )
 {
        LDAP_FREE(mr->mr_oid);
-       LDAP_VFREE(mr->mr_names);
-       LDAP_FREE(mr->mr_desc);
-       LDAP_FREE(mr->mr_syntax_oid);
+       if (mr->mr_names) LDAP_VFREE(mr->mr_names);
+       if (mr->mr_desc) LDAP_FREE(mr->mr_desc);
+       if (mr->mr_syntax_oid) LDAP_FREE(mr->mr_syntax_oid);
        free_extensions(mr->mr_extensions);
        LDAP_FREE(mr);
 }
@@ -1475,9 +1475,9 @@ void
 ldap_matchingruleuse_free( LDAPMatchingRuleUse * mru )
 {
        LDAP_FREE(mru->mru_oid);
-       LDAP_VFREE(mru->mru_names);
-       LDAP_FREE(mru->mru_desc);
-       LDAP_VFREE(mru->mru_applies_oids);
+       if (mru->mru_names) LDAP_VFREE(mru->mru_names);
+       if (mru->mru_desc) LDAP_FREE(mru->mru_desc);
+       if (mru->mru_applies_oids) LDAP_VFREE(mru->mru_applies_oids);
        free_extensions(mru->mru_extensions);
        LDAP_FREE(mru);
 }
@@ -1668,13 +1668,13 @@ void
 ldap_attributetype_free(LDAPAttributeType * at)
 {
        LDAP_FREE(at->at_oid);
-       LDAP_VFREE(at->at_names);
-       LDAP_FREE(at->at_desc);
-       LDAP_FREE(at->at_sup_oid);
-       LDAP_FREE(at->at_equality_oid);
-       LDAP_FREE(at->at_ordering_oid);
-       LDAP_FREE(at->at_substr_oid);
-       LDAP_FREE(at->at_syntax_oid);
+       if (at->at_names) LDAP_VFREE(at->at_names);
+       if (at->at_desc) LDAP_FREE(at->at_desc);
+       if (at->at_sup_oid) LDAP_FREE(at->at_sup_oid);
+       if (at->at_equality_oid) LDAP_FREE(at->at_equality_oid);
+       if (at->at_ordering_oid) LDAP_FREE(at->at_ordering_oid);
+       if (at->at_substr_oid) LDAP_FREE(at->at_substr_oid);
+       if (at->at_syntax_oid) LDAP_FREE(at->at_syntax_oid);
        free_extensions(at->at_extensions);
        LDAP_FREE(at);
 }
@@ -2048,11 +2048,11 @@ void
 ldap_objectclass_free(LDAPObjectClass * oc)
 {
        LDAP_FREE(oc->oc_oid);
-       LDAP_VFREE(oc->oc_names);
-       LDAP_FREE(oc->oc_desc);
-       LDAP_VFREE(oc->oc_sup_oids);
-       LDAP_VFREE(oc->oc_at_oids_must);
-       LDAP_VFREE(oc->oc_at_oids_may);
+       if (oc->oc_names) LDAP_VFREE(oc->oc_names);
+       if (oc->oc_desc) LDAP_FREE(oc->oc_desc);
+       if (oc->oc_sup_oids) LDAP_VFREE(oc->oc_sup_oids);
+       if (oc->oc_at_oids_must) LDAP_VFREE(oc->oc_at_oids_must);
+       if (oc->oc_at_oids_may) LDAP_VFREE(oc->oc_at_oids_may);
        free_extensions(oc->oc_extensions);
        LDAP_FREE(oc);
 }
index 84963423544d48fadb9bb1e22c0bb93338a0b7ad..cc58efeda0ba2724fa3cb8033cfd10c4d0a9b941 100644 (file)
@@ -199,7 +199,7 @@ at_destroy( void )
 
        for (a=attr_list; a; a=n) {
                n = a->sat_next;
-               ldap_memfree(a->sat_subtypes);
+               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);
index 38bb9cfa86e247302889e33b3efa07ae66178b61..f2746e63a9d9e524c52c0d71de0d206881d7b3c0 100644 (file)
@@ -97,8 +97,8 @@ ldbm_back_bind(
                                NULL, NULL, NULL, NULL );
                }
 
-               ber_bvecfree( refs );
-               free( matched_dn );
+               if ( refs ) ber_bvecfree( refs );
+               if ( matched_dn ) free( matched_dn );
                return( rc );
        }
 
index ed47d6b8b98f2b4b96072f5c731d951ad528bb23..de4f04ec91b5286a851beb877b421cff274f3b85 100644 (file)
@@ -82,7 +82,7 @@ ldbm_back_referrals(
                                NULL, NULL );
                }
 
-               free( matched_dn );
+               if ( matched_dn ) free( matched_dn );
                return rc;
        }
 
index 52a28dddd65f48deddacf67f4f5915fc00f475ae..6d6c034b26b3952ff66ceb3669067ad04226c2c3 100644 (file)
@@ -510,7 +510,7 @@ done:
        if( candidates != NULL )
                idl_free( candidates );
 
-       ber_bvecfree( v2refs );
+       if( v2refs ) ber_bvecfree( v2refs );
        if( realbase.bv_val ) free( realbase.bv_val );
 
        return rc;
index 3d521248240079b75a836446fd1af20514939a92..4897cf9901be7eb12021884b7b50921dd54d1679 100644 (file)
@@ -410,19 +410,19 @@ int backend_shutdown( Backend *be )
 int backend_destroy(void)
 {
        int i;
+       BackendDB *bd;
 
        /* destroy each backend database */
-       for( i = 0; i < nBackendDB; i++ ) {
-               if ( backendDB[i].bd_info->bi_db_destroy ) {
-                       backendDB[i].bd_info->bi_db_destroy(
-                               &backendDB[i] );
+       for( i = 0, bd = backendDB; i < nBackendDB; i++, bd++ ) {
+               if ( bd->bd_info->bi_db_destroy ) {
+                       bd->bd_info->bi_db_destroy( bd );
                }
-               ber_bvecfree( backendDB[i].be_suffix );
-               ber_bvecfree( backendDB[i].be_nsuffix );
-               free( backendDB[i].be_rootdn.bv_val );
-               free( backendDB[i].be_rootndn.bv_val );
-               free( backendDB[i].be_rootpw.bv_val );
-               acl_destroy( backendDB[i].be_acl, global_acl );
+               ber_bvecfree( bd->be_suffix );
+               ber_bvecfree( bd->be_nsuffix );
+               if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
+               if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
+               if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
+               acl_destroy( bd->be_acl, global_acl );
        }
        free( backendDB );
 
index 8422587bf3da769069dda6a4b6499b20542eb185..3de3bb9013dcd447d47b178f89daf31dc9e13251 100644 (file)
@@ -28,7 +28,7 @@ const Entry slap_entry_root = { NOID, { 0, "" }, { 0, "" }, NULL, NULL };
 
 int entry_destroy(void)
 {
-       free( ebuf );
+       if ( ebuf ) free( ebuf );
        ebuf = NULL;
        ecur = NULL;
        emaxsize = 0;
index aad1a41a08438da0a94d6f64d867378c879b823b..c39e4001d1985234318bfd3692a146420383a77d 100644 (file)
@@ -362,7 +362,7 @@ get_filter(
                break;
        }
 
-       free( ftmp.bv_val );
+       if ( ftmp.bv_val ) free( ftmp.bv_val );
 
        if ( err != LDAP_SUCCESS ) {
                if ( fstr->bv_val != NULL ) {
index 815da7d4816c424f6a9eb294a5fb2f95b5f8d493..4565883db3181a6a2b8db8d9b592007146ebbfa5 100644 (file)
@@ -383,9 +383,9 @@ cleanup:
        free( pnewrdn.bv_val ); 
        free( nnewrdn.bv_val ); 
 
-       free( newSuperior.bv_val );
-       free( pnewSuperior.bv_val );
-       free( nnewSuperior.bv_val );
+       if ( newSuperior.bv_val ) free( newSuperior.bv_val );
+       if ( pnewSuperior.bv_val ) free( pnewSuperior.bv_val );
+       if ( nnewSuperior.bv_val ) free( nnewSuperior.bv_val );
 
        return rc;
 }
index 73cf9eac255b96b5802f541ca08433dde0681938..173cc82d4b389853ff5560406aad9dd806a8813b 100644 (file)
@@ -294,9 +294,9 @@ oc_destroy( void )
        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);
+               if (o->soc_sups) ldap_memfree(o->soc_sups);
+               if (o->soc_required) ldap_memfree(o->soc_required);
+               if (o->soc_allowed) ldap_memfree(o->soc_allowed);
                ldap_objectclass_free((LDAPObjectClass *)o);
        }
 }