-void xbt_automaton_free_automaton(xbt_automaton_t a, void_f_pvoid_t transition_free_function){
- unsigned int cursor = 0;
- xbt_state_t state = NULL;
- xbt_transition_t transition = NULL;
-
- xbt_dynar_foreach(a->states, cursor, state){
- xbt_dynar_free(&(state->out));
- xbt_dynar_free(&(state->in));
- }
-
- xbt_dynar_foreach(a->transitions, cursor, transition){
- if(transition_free_function)
- (*transition_free_function) (transition->label);
- }
-
- xbt_dynar_foreach(a->states, cursor, state)
- free(state);
- xbt_dynar_free(&(a->states));
-
- xbt_dynar_foreach(a->transitions, cursor, state)
- free(transition);
- xbt_dynar_free(&(a->transitions));
-
- free(a);
-
- return;
-}
-
-void xbt_automaton_free_state(xbt_automaton_t a, xbt_state_t s, void_f_pvoid_t transition_free_function){
- unsigned long nbr;
- unsigned long i;
- unsigned int cursor = 0;
- xbt_state_t state = NULL;
- xbt_transition_t transition = NULL;
-
- nbr = xbt_dynar_length(a->transitions);
- for(i = 0; i <nbr; i++){
- xbt_dynar_get_cpy(a->transitions, cursor, &transition);
- if((transition->src == s) || (transition->dst == s)){
- xbt_automaton_free_transition(a, transition, transition_free_function);
- }else{
- cursor++;
- }
- }
-
- cursor = 0;
- xbt_dynar_foreach(a->states, cursor, state)
- if(state == s)
- xbt_dynar_cursor_rm(a->states, &cursor);
-
- xbt_dynar_free(&(s->in));
- xbt_dynar_free(&(s->out));
-
- free(s);
-
- return;
-}
-
-void xbt_automaton_free_transition(xbt_automaton_t a, xbt_transition_t t, void_f_pvoid_t transition_free_function){
- int index;
- unsigned int cursor = 0;
- xbt_transition_t transition = NULL;
-
- if((transition_free_function) && (t->label))
- (*transition_free_function) (t->label);
-
- xbt_dynar_foreach(a->transitions, cursor, transition) {
- if(transition == t){
- index = __xbt_find_in_dynar(transition->dst->in, transition);
- xbt_dynar_remove_at(transition->dst->in, index, NULL);
- index = __xbt_find_in_dynar(transition->src->out, transition);
- xbt_dynar_remove_at(transition->src->out, index, NULL);
- xbt_dynar_cursor_rm(a->transitions, & cursor);
- free(transition);
- break;
- }
- }
-}
-
-xbt_state_t xbt_automaton_transition_get_source(xbt_transition_t t){