From a0c54f16254f313e29d225de9bcb7049bc1b4e40 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 31 Aug 2002 11:14:15 +0000 Subject: [PATCH] use ldap_charray_add instead of dedicated helper; get rid of dependency from ldap-int.h --- servers/slapd/mr.c | 55 ++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index 46d4c54f49..605dbe8f84 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -15,7 +15,6 @@ #include "slap.h" #include "ldap_pvt.h" -#include "../../libraries/libldap/ldap-int.h" struct mindexrec { struct berval mir_name; @@ -280,33 +279,6 @@ mru_destroy( void ) } } -/* - * Appends a string to an array of char *, - * and returns the newly allocated char **. - * Maybe we can find a substitute, or borrow - * a helper from somewhere else - */ -static char ** -ch_append( char **array, char *value ) -{ - int cnt; - char **tmp; - - if ( array == NULL ) { - cnt = 0; - } else { - for ( cnt = 0; array[ cnt ]; cnt++ ) - /* NO OP */ ; - } - - tmp = LDAP_REALLOC( array, ( cnt + 2 ) * sizeof( char * ) ); - - tmp[ cnt++ ] = ch_strdup( value ); - tmp[ cnt ] = NULL; - - return tmp; -} - int matching_rule_use_init( void ) { @@ -336,6 +308,8 @@ matching_rule_use_init( void ) AttributeType *at; MatchingRuleUse _mru, *mru = &_mru; + char **applies_oids = NULL; + mr->smr_mru = NULL; /* hide rules marked as HIDE */ @@ -397,8 +371,8 @@ matching_rule_use_init( void ) at->sat_oid, at->sat_cname.bv_val, 0 ); #endif - mru->smru_applies_oids - = ch_append( mru->smru_applies_oids, at->sat_oid ); + ldap_charray_add( &applies_oids, + at->sat_oid ); } } @@ -423,8 +397,8 @@ matching_rule_use_init( void ) at->sat_oid, at->sat_cname.bv_val, 0 ); #endif - mru->smru_applies_oids - = ch_append( mru->smru_applies_oids, at->sat_oid ); + ldap_charray_add( &applies_oids, + at->sat_oid ); } } } @@ -452,8 +426,8 @@ matching_rule_use_init( void ) at->sat_oid, at->sat_cname.bv_val, 0 ); #endif - mru->smru_applies_oids - = ch_append( mru->smru_applies_oids, at->sat_oid ); + ldap_charray_add( &applies_oids, + at->sat_oid ); } } break; @@ -480,8 +454,8 @@ matching_rule_use_init( void ) at->sat_oid, at->sat_cname.bv_val, 0 ); #endif - mru->smru_applies_oids - = ch_append( mru->smru_applies_oids, at->sat_oid ); + ldap_charray_add( &applies_oids, + at->sat_oid ); } } break; @@ -505,7 +479,8 @@ matching_rule_use_init( void ) * by any attributeType are not listed as * matchingRuleUse */ - if ( mru->smru_applies_oids != NULL ) { + if ( applies_oids != NULL ) { + mru->smru_applies_oids = applies_oids; #ifdef NEW_LOGGING { char *str = ldap_matchingruleuse2str( &mru->smru_mruleuse ); @@ -520,10 +495,14 @@ matching_rule_use_init( void ) } #endif - mru = (MatchingRuleUse *)LDAP_MALLOC( sizeof( MatchingRuleUse ) ); + mru = (MatchingRuleUse *)ber_memalloc( sizeof( MatchingRuleUse ) ); + /* call-forward from MatchingRule to MatchingRuleUse */ mr->smr_mru = mru; + /* copy static data to newly allocated struct */ *mru = _mru; + /* append the struct pointer to the end of the list */ *mru_ptr = mru; + /* update the list head pointer */ mru_ptr = &mru->smru_next; } } -- 2.39.5