/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
#include "portable.h"
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
-#include "lber.h"
-#include "ldap.h"
#include "ldap-int.h"
{
LDAPMessage *lm, *next;
int err = LDAP_SUCCESS;
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPRequest *lr, *nextlr;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ld->ld_sb.sb_naddr == 0 ) {
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/* free LDAP structure and outstanding requests/responses */
for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
nextlr = lr->lr_next;
while ( ld->ld_conns != NULL ) {
ldap_free_connection( ld, ld->ld_conns, 1, close );
}
-#else /* LDAP_REFERRALS */
+#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( close ) {
err = ldap_send_unbind( ld, &ld->ld_sb );
ldap_close_connection( &ld->ld_sb );
}
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
} else {
int i;
free( ld->ld_ufnprefix );
if ( ld->ld_filtd != NULL )
ldap_getfilter_free( ld->ld_filtd );
-#ifndef LDAP_REFERRALS
+#ifndef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if ( ld->ld_sb.sb_ber.ber_buf != NULL )
free( ld->ld_sb.sb_ber.ber_buf );
-#endif /* !LDAP_REFERRALS */
+#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ld->ld_abandoned != NULL )
free( ld->ld_abandoned );
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if ( ld->ld_selectinfo != NULL )
ldap_free_select_info( ld->ld_selectinfo );
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- if ( ld->ld_defhost != NULL )
- free( ld->ld_defhost );
+ if ( ld->ld_options.ldo_defbase != NULL )
+ free( ld->ld_options.ldo_defbase );
+
+ if ( ld->ld_options.ldo_defhost != NULL )
+ free( ld->ld_options.ldo_defhost );
free( (char *) ld );
+ WSACleanup();
+
return( err );
}