int rewrite_map_destroy( struct rewrite_map **pmap ) { struct rewrite_map *map; assert( pmap != NULL ); assert( *pmap != NULL ); map = *pmap; #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_mutex_lock( &map->lm_mutex ); #endif /* USE_REWRITE_LDAP_PVT_THREADS */ if ( map->lm_name ) { free( map->lm_name ); map->lm_name = NULL; } if ( map->lm_subst ) { rewrite_subst_destroy( &map->lm_subst ); } #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_mutex_unlock( &map->lm_mutex ); ldap_pvt_thread_mutex_destroy( &map->lm_mutex ); #endif /* USE_REWRITE_LDAP_PVT_THREADS */ free( map ); *pmap = NULL; return 0; }
int rewrite_rule_destroy( struct rewrite_rule **prule ) { struct rewrite_rule *rule; assert( prule != NULL ); assert( *prule != NULL ); rule = *prule; if ( rule->lr_pattern ) { free( rule->lr_pattern ); rule->lr_pattern = NULL; } if ( rule->lr_subststring ) { free( rule->lr_subststring ); rule->lr_subststring = NULL; } if ( rule->lr_flagstring ) { free( rule->lr_flagstring ); rule->lr_flagstring = NULL; } if ( rule->lr_subst ) { rewrite_subst_destroy( &rule->lr_subst ); } regfree( &rule->lr_regex ); destroy_actions( rule->lr_action ); free( rule ); *prule = NULL; return 0; }