From: Howard Chu Date: Mon, 5 Feb 2007 04:31:38 +0000 (+0000) Subject: Added ber_bvarray_dup_x() X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~89 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e0ed944be34355cfb1cbfe3396eece4a55696665;p=openldap Added ber_bvarray_dup_x() --- diff --git a/include/lber_pvt.h b/include/lber_pvt.h index 4fb4f28086..f0659a6857 100644 --- a/include/lber_pvt.h +++ b/include/lber_pvt.h @@ -145,6 +145,9 @@ ber_bvarray_free_x LDAP_P(( BerVarray p, void *ctx )); LBER_F( int ) ber_bvarray_add_x LDAP_P(( BerVarray *p, BerValue *bv, void *ctx )); +LBER_F( int ) +ber_bvarray_dup_x LDAP_P(( BerVarray *dst, BerVarray src, void *ctx )); + #if 0 #define ber_bvstrcmp(v1,v2) \ ((v1)->bv_len < (v2)->bv_len \ diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index 375988bbef..0681869862 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -744,6 +744,33 @@ ber_bvarray_free( BerVarray a ) ber_bvarray_free_x(a, NULL); } +int +ber_bvarray_dup_x( BerVarray *dst, BerVarray src, void *ctx ) +{ + int i, j; + BerVarray new; + + if ( !src ) { + *dst = NULL; + return 0; + } + + for (i=0; !BER_BVISNULL( &src[i] ); i++) ; + new = ber_memalloc_x(( i+1 ) * sizeof(BerValue), ctx ); + if ( !new ) + return -1; + for (j=0; j