mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-16 03:44:58 -05:00
Added ber_bvarray_dup_x()
This commit is contained in:
parent
c15ca44c2a
commit
e0ed944be3
2 changed files with 31 additions and 0 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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<i; j++) {
|
||||
ber_dupbv_x( &new[j], &src[j], ctx );
|
||||
if ( BER_BVISNULL( &new[j] )) {
|
||||
ber_bvarray_free_x( new, ctx );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
BER_BVZERO( &new[j] );
|
||||
*dst = new;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ber_bvarray_add_x( BerVarray *a, BerValue *bv, void *ctx )
|
||||
{
|
||||
|
|
@ -784,6 +811,7 @@ ber_bvarray_add_x( BerVarray *a, BerValue *bv, void *ctx )
|
|||
|
||||
(*a)[n++] = *bv;
|
||||
(*a)[n].bv_val = NULL;
|
||||
(*a)[n].bv_len = 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue