-#ifdef LDAP_REFERRALS
- LDAPRequest *lr, *nextlr;
-#endif /* LDAP_REFERRALS */
-
- if ( ld->ld_sb.sb_naddr == 0 ) {
-#ifdef LDAP_REFERRALS
- /* free LDAP structure and outstanding requests/responses */
- for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
- nextlr = lr->lr_next;
- ldap_free_request( ld, lr );
- }
-
- /* free and unbind from all open connections */
- while ( ld->ld_conns != NULL ) {
- ldap_free_connection( ld, ld->ld_conns, 1, close );
- }
-#else /* LDAP_REFERRALS */
- if ( close ) {
- err = ldap_send_unbind( ld, &ld->ld_sb );
- ldap_close_connection( &ld->ld_sb );
- }
-#endif /* LDAP_REFERRALS */
- } else {
- int i;
-
- for ( i = 0; i < ld->ld_sb.sb_naddr; ++i ) {
- free( ld->ld_sb.sb_addrs[ i ] );
- }
- free( ld->ld_sb.sb_addrs );
- free( ld->ld_sb.sb_fromaddr );
+
+ /* free LDAP structure and outstanding requests/responses */
+ while ( ld->ld_requests != NULL ) {
+ ldap_free_request( ld, ld->ld_requests );
+ }
+
+ /* free and unbind from all open connections */
+ while ( ld->ld_conns != NULL ) {
+ ldap_free_connection( ld, ld->ld_conns, 1, close );