#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
#include <ac/socket.h>
#include <ac/string.h>
return( NULL );
}
- if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
+ if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
- strdup( ld->ld_defhost )) == NULL )) {
- if(srv != NULL) free( (char*) srv );
+ LDAP_STRDUP( ld->ld_defhost )) == NULL )) {
+ if(srv != NULL) LDAP_FREE( (char*) srv );
ldap_ld_free( ld, 0, NULL, NULL );
return( NULL );
}
srv->lsrv_port = ld->ld_defport;
if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 )) == NULL ) {
- if ( ld->ld_defhost != NULL ) free( srv->lsrv_host );
- free( (char *)srv );
+ if ( ld->ld_defhost != NULL ) LDAP_FREE( srv->lsrv_host );
+ LDAP_FREE( (char *)srv );
ldap_ld_free( ld, 0, NULL, NULL );
return( NULL );
}
{
LDAP *ld;
- if(!openldap_ldap_initialized) {
- openldap_ldap_initialize();
+ if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) {
+ ldap_int_initialize();
}
Debug( LDAP_DEBUG_TRACE, "ldap_init\n", 0, 0, 0 );
}
#endif
- if ( (ld = (LDAP *) calloc( 1, sizeof(LDAP) )) == NULL ) {
+ if ( (ld = (LDAP *) LDAP_CALLOC( 1, sizeof(LDAP) )) == NULL ) {
WSACleanup( );
return( NULL );
}
/* copy the global options */
- memcpy(&ld->ld_options, &openldap_ldap_global_options,
+ memcpy(&ld->ld_options, &ldap_int_global_options,
sizeof(ld->ld_options));
+ ld->ld_valid = LDAP_VALID_SESSION;
+
/* but not pointers to malloc'ed items */
ld->ld_options.ldo_defbase = NULL;
ld->ld_options.ldo_defhost = NULL;
ld->ld_options.ldo_cctrls = NULL;
if ( defhost != NULL ) {
- ld->ld_options.ldo_defhost = strdup( defhost );
+ ld->ld_options.ldo_defhost = LDAP_STRDUP( defhost );
} else {
- ld->ld_options.ldo_defhost = strdup(
- openldap_ldap_global_options.ldo_defhost);
+ ld->ld_options.ldo_defhost = LDAP_STRDUP(
+ ldap_int_global_options.ldo_defhost);
}
if ( ld->ld_options.ldo_defhost == NULL ) {
- free( (char*)ld );
+ LDAP_FREE( (char*)ld );
WSACleanup( );
return( NULL );
}
- if ( openldap_ldap_global_options.ldo_defbase != NULL ) {
- ld->ld_options.ldo_defbase = strdup(
- openldap_ldap_global_options.ldo_defbase);
+ if ( ldap_int_global_options.ldo_defbase != NULL ) {
+ ld->ld_options.ldo_defbase = LDAP_STRDUP(
+ ldap_int_global_options.ldo_defbase);
}
if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
- free( (char*) ld->ld_options.ldo_defhost );
+ LDAP_FREE( (char*) ld->ld_options.ldo_defhost );
if ( ld->ld_options.ldo_defbase == NULL ) {
- free( (char*) ld->ld_options.ldo_defbase );
+ LDAP_FREE( (char*) ld->ld_options.ldo_defbase );
}
- free( (char*) ld );
+ LDAP_FREE( (char*) ld );
WSACleanup( );
return( NULL );
}