From: Pierangelo Masarati Date: Fri, 14 Nov 2003 20:00:20 +0000 (+0000) Subject: more cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~444 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cddeab8513e951f21b5fe845df1cbac3730d023d;p=openldap more cleanup --- diff --git a/libraries/librewrite/info.c b/libraries/librewrite/info.c index aeb43d6ee6..723cdbc1ec 100644 --- a/libraries/librewrite/info.c +++ b/libraries/librewrite/info.c @@ -117,6 +117,11 @@ rewrite_info_delete( } info->li_context = NULL; + if ( info->li_maps ) { + avl_free( info->li_maps, rewrite_builtin_map_free ); + } + info->li_context = NULL; + rewrite_session_destroy( info ); #ifdef USE_REWRITE_LDAP_PVT_THREADS @@ -172,7 +177,7 @@ rewrite_session( ) { struct rewrite_context *context; - struct rewrite_op op = { 0, 0, NULL, NULL, NULL, NULL }; + struct rewrite_op op = { 0, 0, NULL, NULL, NULL }; int rc; assert( info != NULL ); @@ -218,21 +223,24 @@ rewrite_session( break; } } - + +#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */ op.lo_string = strdup( string ); if ( op.lo_string == NULL ) { rc = REWRITE_REGEXEC_ERR; goto rc_return; } +#endif /* * Applies rewrite context */ - rc = rewrite_context_apply(info, &op, context, string, result ); + rc = rewrite_context_apply( info, &op, context, string, result ); assert( op.lo_depth == 0 ); - /* ?!? */ +#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */ free( op.lo_string ); +#endif switch ( rc ) { /* diff --git a/libraries/librewrite/ldapmap.c b/libraries/librewrite/ldapmap.c index 6f83ff7aa3..07e04bccf2 100644 --- a/libraries/librewrite/ldapmap.c +++ b/libraries/librewrite/ldapmap.c @@ -331,3 +331,21 @@ rc_return:; return rc; } +int +map_ldap_destroy( + struct rewrite_builtin_map **pmap +) +{ + struct ldap_map_data *data; + + assert( pmap ); + assert( *pmap ); + + data = ( struct ldap_map_data * )(*pmap)->lb_private; + + free( data ); + *pmap = NULL; + + return 0; +} + diff --git a/libraries/librewrite/map.c b/libraries/librewrite/map.c index c7acbc31eb..cf563f079c 100644 --- a/libraries/librewrite/map.c +++ b/libraries/librewrite/map.c @@ -436,6 +436,28 @@ rewrite_map_apply( return rc; } +void +rewrite_builtin_map_free( + void *tmp +) +{ + struct rewrite_builtin_map *map = ( struct rewrite_builtin_map * )tmp; + + assert( map ); + + switch ( map->lb_type ) { + case REWRITE_BUILTIN_MAP_LDAP: + map_ldap_destroy( &map ); + break; + + default: + assert(0); + break; + } + + free( map ); +} + int rewrite_map_destroy( struct rewrite_map **pmap diff --git a/libraries/librewrite/rewrite-int.h b/libraries/librewrite/rewrite-int.h index c30e617b2f..85358b72fc 100644 --- a/libraries/librewrite/rewrite-int.h +++ b/libraries/librewrite/rewrite-int.h @@ -262,7 +262,9 @@ struct rewrite_var { struct rewrite_op { int lo_num_passes; int lo_depth; +#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */ char *lo_string; +#endif char *lo_result; Avlnode *lo_vars; const void *lo_cookie; @@ -369,6 +371,10 @@ rewrite_xmap_destroy( struct rewrite_map **map ); +LDAP_REWRITE_F (void) +rewrite_builtin_map_free( + void *map +); /* * Submatch substitution */ diff --git a/libraries/librewrite/rewrite-map.h b/libraries/librewrite/rewrite-map.h index 918dc4b063..13283e4bed 100644 --- a/libraries/librewrite/rewrite-map.h +++ b/libraries/librewrite/rewrite-map.h @@ -53,4 +53,7 @@ map_ldap_apply( struct rewrite_builtin_map *map, struct berval *val ); +LDAP_REWRITE_F (int) +map_ldap_destroy( struct rewrite_builtin_map **map ); + #endif /* MAP_H */ diff --git a/libraries/librewrite/subst.c b/libraries/librewrite/subst.c index 6aafac5118..531b09900b 100644 --- a/libraries/librewrite/subst.c +++ b/libraries/librewrite/subst.c @@ -180,7 +180,6 @@ rewrite_subst_compile( free( submatch ); return NULL; } - subs = tmps; l = p - begin; if ( l > 0 ) { diff --git a/libraries/librewrite/var.c b/libraries/librewrite/var.c index e701655a86..aa39261ce5 100644 --- a/libraries/librewrite/var.c +++ b/libraries/librewrite/var.c @@ -110,7 +110,7 @@ rewrite_var_insert( return NULL; } memset( var, 0, sizeof( struct rewrite_var ) ); - var->lv_name = ( char * )strdup( name ); + var->lv_name = strdup( name ); if ( var->lv_name == NULL ) { rc = -1; goto cleanup; @@ -190,6 +190,7 @@ rewrite_var_free( free( var->lv_name ); free( var->lv_value.bv_val ); + free( var ); } /*