Re: Modifying the modification
Emmanuel Dreyfus <[email protected]> Fri, 13 Feb 2026 02:00:52 +0000
| Newsgroups | gmane.network.openldap.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Feb 12, 2026 at 03:25:33PM +0000, Howard Chu wrote:
> Modify is fine. For add, you should use attr_free(), not attr_clean() + free().
Thank you for the review.
I also have the need toremove a single attribute value for modify or add.
I wonder if I need to take care of SLAP_ATTR_DONT_FREE_DATA and
SLAP_ATTR_DONT_FREE_VALS in the add caze.
static void
supann_attr_rmval(Attribute *a, int index)
{
struct berval *nbv;
int j;
nbv = &a->a_vals[index];
ber_memfree_x(nbv->bv_val, NULL);
nbv->bv_val = NULL;
if (a->a_nvals && a->a_nvals != a->a_vals) {
nbv = &a->a_nvals[index];
ber_memfree_x(nbv->bv_val, NULL);
nbv->bv_val = NULL;
}
a->a_numvals--;
/*
* a->a_vals[j + 1] does not overflow since
* we just decreased a->a_numvals
*/
for (j = index; j < a->a_numvals; j++)
a->a_vals[j] = a->a_vals[j + 1];
a->a_vals[a->a_numvals].bv_val = NULL;
a->a_vals[a->a_numvals].bv_len = 0;
if (a->a_nvals && a->a_nvals != a->a_vals) {
for (j = index; j < a->a_numvals; j++)
a->a_nvals[j] = a->a_nvals[j + 1];
a->a_nvals[a->a_numvals].bv_val = NULL;
a->a_nvals[a->a_numvals].bv_len = 0;
}
return;
}
--
Emmanuel Dreyfus
[email protected]