From: Kurt Zeilenga Date: Sat, 16 Sep 2000 22:46:04 +0000 (+0000) Subject: cleanup X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1962 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e1b73eda9373ea3bddd532727a2987363dc3c108;p=openldap cleanup --- diff --git a/libraries/libldap/charray.c b/libraries/libldap/charray.c index 82d2feeb1b..41432d21b4 100644 --- a/libraries/libldap/charray.c +++ b/libraries/libldap/charray.c @@ -221,25 +221,26 @@ ldap_str2charray( const char *str_in, const char *brkstr ) char * ldap_charray2str( char **a, const char *sep ) { char *s, **v, *p; - int len = 0; + int len; int slen; if( sep == NULL ) sep = " "; slen = strlen( sep ); + len = 0; for ( v = a; *v != NULL; v++ ) { - len += strlen( *v ) + slen; /* for a space */ + len += strlen( *v ) + slen; } if ( len == 0 ) { return NULL; } + /* trim extra sep len */ len -= slen; - len += 1; /* EOS */ - s = LDAP_MALLOC ( len ); + s = LDAP_MALLOC ( len + 1 ); if ( s == NULL ) { return NULL; @@ -247,8 +248,6 @@ char * ldap_charray2str( char **a, const char *sep ) p = s; for ( v = a; *v != NULL; v++ ) { - int len; - if ( v != a ) { strncpy( p, sep, slen ); p += slen;