From 0d475ca4f05e5e2e79b11b7cfc95e587af5358ed Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 19 Jan 2005 00:12:46 +0000 Subject: [PATCH] cleanup --- servers/slapd/config.c | 11 +++-------- servers/slapd/slap.h | 3 +-- servers/slapd/syncrepl.c | 13 +++++-------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 16c382f919..8695fcd11c 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -1681,7 +1681,8 @@ add_syncrepl( } else { Debug( LDAP_DEBUG_CONFIG, "Config: ** successfully added syncrepl \"%s\"\n", - si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 ); + BER_BVISNULL( &si->si_provideruri ) ? + "(null)" : si->si_provideruri.bv_val, 0, 0 ); if ( !si->si_schemachecking ) { SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK; } @@ -1770,13 +1771,7 @@ parse_syncrepl_line( STRLENOF( PROVIDERSTR "=" ) ) ) { val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" ); - si->si_provideruri = ch_strdup( val ); - si->si_provideruri_bv = (BerVarray) - ch_calloc( 2, sizeof( struct berval )); - ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ), - 1, &si->si_provideruri_bv[0] ); - si->si_provideruri_bv[1].bv_len = 0; - si->si_provideruri_bv[1].bv_val = NULL; + ber_str2bv( val, 0, 1, &si->si_provideruri ); gots |= GOT_PROVIDER; } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=", STRLENOF(STARTTLSSTR "=") ) ) diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index edcaae20f2..aa356b80f5 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1481,8 +1481,7 @@ LDAP_STAILQ_HEAD( slap_sync_cookie_s, sync_cookie ); typedef struct syncinfo_s { struct slap_backend_db *si_be; long si_rid; - char *si_provideruri; - BerVarray si_provideruri_bv; + struct berval si_provideruri; #define SYNCINFO_TLS_OFF 0 #define SYNCINFO_TLS_ON 1 #define SYNCINFO_TLS_CRITICAL 2 diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 6896b1da66..ec9f08280b 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -282,11 +282,11 @@ do_syncrep1( psub = &si->si_be->be_nsuffix[0]; /* Init connection to master */ - rc = ldap_initialize( &si->si_ld, si->si_provideruri ); + rc = ldap_initialize( &si->si_ld, si->si_provideruri.bv_val ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "do_syncrep1: ldap_initialize failed (%s)\n", - si->si_provideruri, 0, 0 ); + si->si_provideruri.bv_val, 0, 0 ); return rc; } @@ -317,7 +317,7 @@ do_syncrep1( if( rc != LDAP_OPT_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option " "(%s,SECPROPS,\"%s\") failed!\n", - si->si_provideruri, si->si_secprops, 0 ); + si->si_provideruri.bv_val, si->si_secprops, 0 ); goto done; } } @@ -2074,11 +2074,8 @@ avl_ber_bvfree( void *v_bv ) void syncinfo_free( syncinfo_t *sie ) { - if ( sie->si_provideruri ) { - ch_free( sie->si_provideruri ); - } - if ( sie->si_provideruri_bv ) { - ber_bvarray_free( sie->si_provideruri_bv ); + if ( !BER_BVISNULL( &sie->si_provideruri ) ) { + ch_free( sie->si_provideruri.bv_val ); } if ( sie->si_binddn ) { ch_free( sie->si_binddn ); -- 2.39.5