introduce ber_bvreplace()

This commit is contained in:
Pierangelo Masarati 2005-04-21 03:40:50 +00:00
parent 637df0ba90
commit 2f877b48b1
3 changed files with 33 additions and 0 deletions

View File

@ -597,6 +597,10 @@ LBER_F( char * )
ber_strdup LDAP_P((
LDAP_CONST char * ));
LBER_F( struct berval * )
ber_bvreplace LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src ));
LBER_F( void )
ber_bvarray_free LDAP_P(( BerVarray p ));

View File

@ -135,6 +135,10 @@ LBER_F( char * )
ber_strdup_x LDAP_P((
LDAP_CONST char *, void *ctx ));
LBER_F( struct berval * )
ber_bvreplace_x LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src, void *ctx ));
LBER_F( void )
ber_bvarray_free_x LDAP_P(( BerVarray p, void *ctx ));

View File

@ -713,6 +713,31 @@ ber_strndup( LDAP_CONST char *s, ber_len_t l )
return ber_strndup_x( s, l, NULL );
}
/*
* dst is resized as required by src and the value of src is copied into dst
* dst->bv_val must be NULL (and dst->bv_len must be 0), or it must be
* alloc'ed with the context ctx
*/
struct berval *
ber_bvreplace_x( struct berval *dst, LDAP_CONST struct berval *src, void *ctx )
{
assert( dst != NULL );
if ( dst->bv_len < src->bv_len ) {
dst->bv_val = ber_memrealloc_x( dst->bv_val, src->bv_len + 1, ctx );
}
AC_MEMCPY( dst->bv_val, src->bv_val, src->bv_len + 1 );
return dst;
}
struct berval *
ber_bvreplace( struct berval *dst, LDAP_CONST struct berval *src )
{
return ber_bvreplace_x( dst, src, NULL );
}
void
ber_bvarray_free_x( BerVarray a, void *ctx )
{