From 92e23b13bd8f4821daaeff3aebdddbff4dadb84b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 4 Mar 2008 09:43:51 +0000 Subject: [PATCH] Add attr_free_x() - use memctx --- servers/slapd/attr.c | 26 +++++++++++++++++++------- servers/slapd/proto-slap.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index e54ed671be..be18e429ef 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -124,14 +124,14 @@ attrs_alloc( int num ) void -attr_clean( Attribute *a ) +attr_clean_x( Attribute *a, void *ctx ) { if ( a->a_nvals && a->a_nvals != a->a_vals && !( a->a_flags & SLAP_ATTR_DONT_FREE_VALS )) { if ( a->a_flags & SLAP_ATTR_DONT_FREE_DATA ) { - free( a->a_nvals ); + ber_memfree_x( a->a_nvals, ctx ); } else { - ber_bvarray_free( a->a_nvals ); + ber_bvarray_free_x( a->a_nvals, ctx ); } } /* a_vals may be equal to slap_dummy_bv, a static empty berval; @@ -141,9 +141,9 @@ attr_clean( Attribute *a ) if ( a->a_vals != &slap_dummy_bv && !( a->a_flags & SLAP_ATTR_DONT_FREE_VALS )) { if ( a->a_flags & SLAP_ATTR_DONT_FREE_DATA ) { - free( a->a_vals ); + ber_memfree_x( a->a_vals, ctx ); } else { - ber_bvarray_free( a->a_vals ); + ber_bvarray_free_x( a->a_vals, ctx ); } } a->a_desc = NULL; @@ -156,6 +156,12 @@ attr_clean( Attribute *a ) a->a_numvals = 0; } +void +attr_clean( Attribute *a ) +{ + attr_clean_x( a, NULL ); +} + void attr_free( Attribute *a ) { @@ -184,7 +190,7 @@ comp_tree_free( Attribute *a ) #endif void -attrs_free( Attribute *a ) +attrs_free_x( Attribute *a, void *ctx ) { if ( a ) { Attribute *b = (Attribute *)0xBAD, *tail, *next; @@ -193,7 +199,7 @@ attrs_free( Attribute *a ) tail = a; do { next = a->a_next; - attr_clean( a ); + attr_clean_x( a, ctx ); a->a_next = b; b = a; a = next; @@ -208,6 +214,12 @@ attrs_free( Attribute *a ) } } +void +attrs_free( Attribute *a ) +{ + attrs_free_x( a, NULL ); +} + static void attr_dup2( Attribute *tmp, Attribute *a ) { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 69234d99fc..5911054472 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -303,6 +303,7 @@ LDAP_SLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc )); LDAP_SLAPD_F (void) attrs_free LDAP_P(( Attribute *a )); +LDAP_SLAPD_F (void) attrs_free_x LDAP_P(( Attribute *a, void *ctx )); LDAP_SLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a )); LDAP_SLAPD_F (int) attr_init LDAP_P(( void )); LDAP_SLAPD_F (int) attr_destroy LDAP_P(( void )); -- 2.39.5