/* * Search the value set for each value to be update, * and update the value with the CSN provided. * Updated values are moved from the valuestoupdate * array to the valueupdated array. */ void valueset_update_csn_for_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated) { if(!valuearray_isempty(valuestoupdate) && !valuearray_isempty(vs->va)) { /* * determine whether we should use an AVL tree of values or not */ struct valuearrayfast vaf_valuesupdated; int numberofvaluestoupdate= valuearray_count(valuestoupdate); valuearrayfast_init(&vaf_valuesupdated,*valuesupdated); if (numberofvaluestoupdate > 1) /* multiple values to update */ { int i; Avlnode *vtree = NULL; int rc= valuetree_add_valuearray( a, vs->va, &vtree, NULL ); PR_ASSERT(rc==LDAP_SUCCESS); for (i=0;valuestoupdate[i]!=NULL;++i) { int index= 0; rc = valuetree_find( a, valuestoupdate[i], vtree, &index ); if(rc==LDAP_SUCCESS) { value_update_csn(vs->va[index],t,csn); valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]); valuestoupdate[i] = NULL; } } valuetree_free(&vtree); } else { int i; for (i=0;valuestoupdate[i]!=NULL;++i) { int index= valuearray_find(a, vs->va, valuestoupdate[i]); if(index!=-1) { value_update_csn(vs->va[index],t,csn); valuearrayfast_add_value_passin(&vaf_valuesupdated,valuestoupdate[i]); valuestoupdate[i]= NULL; } } } valuearray_compress(valuestoupdate,numberofvaluestoupdate); *valuesupdated= vaf_valuesupdated.va; } }
void valuearray_update_csn(Slapi_Value **va, CSNType t, const CSN *csn) { int i; for (i = 0; va!=NULL && va[i]; i++) { value_update_csn(va[i],t,csn); } }
Slapi_Value * value_init(Slapi_Value *v, const struct berval *bval,CSNType t,const CSN *csn) { PR_ASSERT(v!=NULL); memset(v,0,sizeof(Slapi_Value)); if(csn!=NULL) { value_update_csn(v,t,csn); } slapi_value_set_berval(v,bval); return v; }