A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update copyright lines for 2023.
[simgrid.git]
/
src
/
xbt
/
automaton
/
automaton.c
diff --git
a/src/xbt/automaton/automaton.c
b/src/xbt/automaton/automaton.c
index
1d6be9f
..
f44bf6d
100644
(file)
--- a/
src/xbt/automaton/automaton.c
+++ b/
src/xbt/automaton/automaton.c
@@
-1,6
+1,6
@@
/* automaton - representation of büchi automaton */
/* automaton - representation of büchi automaton */
-/* Copyright (c) 2011-202
0
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-202
3
. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
@@
-33,8
+33,8
@@
xbt_automaton_state_t xbt_automaton_state_new(const_xbt_automaton_t a, int type,
xbt_automaton_state_t state = xbt_new0(struct xbt_automaton_state, 1);
state->type = type;
state->id = xbt_strdup(id);
xbt_automaton_state_t state = xbt_new0(struct xbt_automaton_state, 1);
state->type = type;
state->id = xbt_strdup(id);
- state->in
= xbt_dynar_new(sizeof(xbt_automaton_transition_t), xbt_automaton_transition_free_voidp
);
- state->out
= xbt_dynar_new(sizeof(xbt_automaton_transition_t), xbt_automaton_transition_free_voidp
);
+ state->in
= xbt_dynar_new(sizeof(xbt_automaton_transition_t), NULL
);
+ state->out
= xbt_dynar_new(sizeof(xbt_automaton_transition_t), NULL
);
xbt_dynar_push(a->states, &state);
return state;
}
xbt_dynar_push(a->states, &state);
return state;
}
@@
-329,9
+329,9
@@
int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xb
int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
{
int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
{
- unsigned
int
nb_elem = xbt_dynar_length(s1);
+ unsigned
long
nb_elem = xbt_dynar_length(s1);
- for (unsigned
int
cursor = 0; cursor < nb_elem; cursor++) {
+ for (unsigned
long
cursor = 0; cursor < nb_elem; cursor++) {
const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
@@
-346,12
+346,12
@@
static void xbt_automaton_exp_label_free(xbt_automaton_exp_label_t e);
static void xbt_automaton_propositional_symbol_free(xbt_automaton_propositional_symbol_t ps);
void xbt_automaton_state_free(xbt_automaton_state_t s){
static void xbt_automaton_propositional_symbol_free(xbt_automaton_propositional_symbol_t ps);
void xbt_automaton_state_free(xbt_automaton_state_t s){
- if (s
!= NULL) {
-
xbt_free(s->id)
;
-
xbt_dynar_free(&(s->in)
);
-
xbt_dynar_free(&(s->out
));
-
xbt_free(s
);
- }
+ if (s
== NULL)
+
return
;
+
xbt_free(s->id
);
+
xbt_dynar_free(&(s->in
));
+
xbt_dynar_free(&(s->out)
);
+ xbt_free(s);
}
void xbt_automaton_state_free_voidp(void *s){
}
void xbt_automaton_state_free_voidp(void *s){
@@
-359,11
+359,10
@@
void xbt_automaton_state_free_voidp(void *s){
}
static void xbt_automaton_transition_free(xbt_automaton_transition_t t){
}
static void xbt_automaton_transition_free(xbt_automaton_transition_t t){
- if(t){
- xbt_automaton_exp_label_free(t->label);
- xbt_free(t);
- t = NULL;
- }
+ if (t == NULL)
+ return;
+ xbt_automaton_exp_label_free(t->label);
+ xbt_free(t);
}
void xbt_automaton_transition_free_voidp(void *t){
}
void xbt_automaton_transition_free_voidp(void *t){
@@
-371,25
+370,24
@@
void xbt_automaton_transition_free_voidp(void *t){
}
static void xbt_automaton_exp_label_free(xbt_automaton_exp_label_t e){
}
static void xbt_automaton_exp_label_free(xbt_automaton_exp_label_t e){
- if(e){
- switch(e->type){
- case 0:
- case 1:
+ if (e == NULL)
+ return;
+ switch (e->type) {
+ case AUT_OR:
+ case AUT_AND:
xbt_automaton_exp_label_free(e->u.or_and.left_exp);
xbt_automaton_exp_label_free(e->u.or_and.right_exp);
break;
xbt_automaton_exp_label_free(e->u.or_and.left_exp);
xbt_automaton_exp_label_free(e->u.or_and.right_exp);
break;
- case
2
:
+ case
AUT_NOT
:
xbt_automaton_exp_label_free(e->u.exp_not);
break;
xbt_automaton_exp_label_free(e->u.exp_not);
break;
- case
3
:
+ case
AUT_PREDICAT
:
xbt_free(e->u.predicat);
break;
default:
break;
xbt_free(e->u.predicat);
break;
default:
break;
- }
- xbt_free(e);
- e = NULL;
}
}
+ xbt_free(e);
}
void xbt_automaton_exp_label_free_voidp(void *e){
}
void xbt_automaton_exp_label_free_voidp(void *e){
@@
-397,27
+395,23
@@
void xbt_automaton_exp_label_free_voidp(void *e){
}
static void xbt_automaton_propositional_symbol_free(xbt_automaton_propositional_symbol_t ps){
}
static void xbt_automaton_propositional_symbol_free(xbt_automaton_propositional_symbol_t ps){
- if(ps){
- xbt_free(ps->pred);
- xbt_free(ps);
- ps = NULL;
- }
+ if (ps == NULL)
+ return;
+ if (ps->free_function)
+ ps->free_function(ps->data);
+ xbt_free(ps->pred);
+ xbt_free(ps);
}
void xbt_automaton_propositional_symbol_free_voidp(void *ps){
}
void xbt_automaton_propositional_symbol_free_voidp(void *ps){
- xbt_automaton_propositional_symbol_t symbol = (xbt_automaton_propositional_symbol_t) * (void **) ps;
- if (symbol->free_function)
- symbol->free_function(symbol->data);
- xbt_automaton_propositional_symbol_free(symbol);
+ xbt_automaton_propositional_symbol_free((xbt_automaton_propositional_symbol_t) * (void**)ps);
}
void xbt_automaton_free(xbt_automaton_t a){
}
void xbt_automaton_free(xbt_automaton_t a){
- if(a){
- xbt_dynar_free(&(a->propositional_symbols));
- xbt_dynar_free(&(a->transitions));
- xbt_dynar_free(&(a->states));
- xbt_automaton_state_free(a->current_state);
- xbt_free(a);
- a = NULL;
- }
+ if (a == NULL)
+ return;
+ xbt_dynar_free(&(a->propositional_symbols));
+ xbt_dynar_free(&(a->transitions));
+ xbt_dynar_free(&(a->states));
+ xbt_free(a);
}
}