Commit cddeab85 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

more cleanup

parent 75244afd
......@@ -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 ) {
/*
......
......@@ -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;
}
......@@ -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
......
......@@ -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
*/
......
......@@ -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 */
......@@ -180,7 +180,6 @@ rewrite_subst_compile(
free( submatch );
return NULL;
}
subs = tmps;
l = p - begin;
if ( l > 0 ) {
......
......@@ -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 );
}
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment