Skip to content
Snippets Groups Projects
Commit e0ed944b authored by Howard Chu's avatar Howard Chu
Browse files

Added ber_bvarray_dup_x()

parent c15ca44c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment