From: Howard Chu Date: Fri, 29 Dec 2006 01:00:24 +0000 (+0000) Subject: streamline attrs_free X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~294 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6222b79bc81f752790b3ae875a8669de07870c9b;p=openldap streamline attrs_free --- diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 5cf97ec67e..3c397c64f2 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -124,7 +124,7 @@ attrs_alloc( int num ) void -attr_free( Attribute *a ) +attr_clean( Attribute *a ) { if ( a->a_nvals && a->a_nvals != a->a_vals && !( a->a_flags & SLAP_ATTR_DONT_FREE_VALS )) { @@ -146,7 +146,19 @@ attr_free( Attribute *a ) ber_bvarray_free( a->a_vals ); } } - memset( a, 0, sizeof( Attribute )); + a->a_desc = NULL; + a->a_vals = NULL; + a->a_nvals = NULL; +#ifdef LDAP_COMP_MATCH + a->a_comp_data = NULL; +#endif + a->a_flags = 0; +} + +void +attr_free( Attribute *a ) +{ + attr_clean( a ); ldap_pvt_thread_mutex_lock( &attr_mutex ); a->a_next = attr_list; attr_list = a; @@ -173,15 +185,19 @@ comp_tree_free( Attribute *a ) void attrs_free( Attribute *a ) { - Attribute *next; + Attribute *b; - for( ; a != NULL ; a = next ) { - next = a->a_next; - attr_free( a ); + for(b = a ; b != NULL ; b = b->a_next ) { + attr_clean( b ); + if ( !b->a_next ) + break; } + ldap_pvt_thread_mutex_lock( &attr_mutex ); + b->a_next = attr_list; + attr_list = a; + ldap_pvt_thread_mutex_unlock( &attr_mutex ); } - static void attr_dup2( Attribute *tmp, Attribute *a ) {