return 1;
}
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
int rc;
struct berval cred = BER_BVC("");
int msgid;
return 0;
}
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ) && i < candidate;
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ) && i < candidate;
++i, ++lsc );
if ( !META_LAST( lsc ) ) {
}
} else {
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
char *msg = NULL;
char *match = NULL;
dc.rs = rs;
dc.ctx = "compareDN";
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
struct berval mdn = BER_BVNULL;
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
struct berval mapped_value = op->orc_ava->aa_value;
/*
* FIXME: should we check for abandon?
*/
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++, i++ ) {
int lrc;
LDAPMessage *res = NULL;
assert( ntargets > 0 );
- lc = ch_calloc( sizeof( struct metaconn ), 1 );
+ /* malloc once only; leave an extra one for one-past-end */
+ lc = ch_malloc( sizeof( struct metaconn )
+ + sizeof( struct metasingleconn ) * ( ntargets + 1 ) );
if ( lc == NULL ) {
return NULL;
}
-
- /*
- * make it a null-terminated array ...
- */
- lc->mc_conns = ch_calloc( sizeof( struct metasingleconn ), ntargets + 1 );
- if ( lc->mc_conns == NULL ) {
- free( lc );
- return NULL;
- }
+
+ lc->mc_conns = (struct metasingleconn *)&lc[ 1 ];
/* FIXME: needed by META_LAST() */
lc->mc_conns[ ntargets ].msc_candidate = META_LAST_CONN;
return;
}
- if ( lc->mc_conns ) {
- ch_free( lc->mc_conns );
- }
-
free( lc );
}
struct metaconn *lc = v_lc;
struct metasingleconn *lsc;
- for ( lsc = lc->mc_conns; !META_LAST( lsc ); lsc++ ) {
+ assert( lc->mc_conns != NULL );
+
+ for ( lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++ ) {
if ( lsc->msc_ld != NULL ) {
ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
}
ber_memfree( lsc->msc_cred.bv_val );
}
}
- free( lc->mc_conns );
+
free( lc );
}
/*
* Inits searches
*/
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
struct berval realbase = op->o_req_dn;
int realscope = op->ors_scope;
ber_len_t suffixlen = 0;
/* check for abandon */
ab = op->o_abandon;
- for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
+ for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++, i++ ) {
if ( msgid[ i ] == -1 ) {
continue;
}
#include <ac/socket.h>
#include <ac/string.h>
+#include <ac/errno.h>
#include "slap.h"
#include "../back-ldap/back-ldap.h"
rewrite_session_delete( li->mi_targets[ i ]->mt_rwmap.rwm_rw, conn );
meta_clear_one_candidate( &lc->mc_conns[ i ] );
}
-
- free( lc->mc_conns );
free( lc );
}