[Date Prev][Date Next] [Chronological] [Thread] [Top]

Free Attribute with dummy empty values



In back-ldap we've a piece of code like this

	if ( a->a_nvals != a->a_vals ) {
		ber_bvarray_free( a->a_nvals );
	}
	if ( a->a_vals != &slap_dummy_bv ) {
		ber_bvarray_free( a->a_vals );
	}
	ch_free( a );

that is used to free an Attribute when the value may be set to &slap_dummy_bv to indicate that's empty (e.g. attrsonly) without allocating a BER_BVNULL.  I think this test could move to attr_free(), like

diff -u -r1.106 attr.c
--- servers/slapd/attr.c	21 Apr 2005 21:35:00 -0000	1.106
+++ servers/slapd/attr.c	12 May 2005 23:02:33 -0000
@@ -46,7 +46,9 @@
	if ( a->a_nvals && a->a_nvals != a->a_vals ) {
		ber_bvarray_free( a->a_nvals );
	}
-	ber_bvarray_free( a->a_vals );
+	if ( a->a_vals != &slap_dummy_bv ) {
+		ber_bvarray_free( a->a_vals );
+	}
	free( a );
}

so that it can be used elsewhere.  This would allow, for instance, back-ldap/back-meta to send entries marked as REP_ENTRY_MODIFIABLE.

Comments?

p.



   SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497