[C] malloc->calloc + conditions merged in free_state_*
This commit is contained in:
parent
a673c447e3
commit
8c3e3d1eac
@ -237,7 +237,7 @@ let cp_init_aux_nodes fmt (node, h) =
|
||||
| Some n ->
|
||||
begin
|
||||
Format.fprintf fmt "%a\t\tif(!state->is_reset) {\n\
|
||||
\t\t\tstate->aux_states[%d] = malloc (sizeof (%s));\n\
|
||||
\t\t\tstate->aux_states[%d] = calloc (1, sizeof (%s));\n\
|
||||
\t\t}\n\
|
||||
\t\t((%s*)(state->aux_states[%d]))->is_init = true;\n\
|
||||
\t\t((%s*)(state->aux_states[%d]))->is_reset = state->is_reset;\n"
|
||||
|
@ -91,11 +91,14 @@ let cp_state_frees fmt (iprog, sts) =
|
||||
| None -> ()
|
||||
| Some callee_name ->
|
||||
let callee_st = Hashtbl.find sts callee_name in
|
||||
if callee_st.nt_count_app > 0 then
|
||||
Format.fprintf fmt "\tif (st->aux_states[%d])\n\
|
||||
\t\tfree_state_%s((t_state_%s*)(st->aux_states[%d]));\n"
|
||||
idx callee_name callee_name idx;
|
||||
Format.fprintf fmt "\tif (st->aux_states[%d])\n\
|
||||
if callee_st.nt_count_app > 0
|
||||
then
|
||||
Format.fprintf fmt "\tif (st->aux_states[%d]) {\n\
|
||||
\t\tfree_state_%s((t_state_%s*)(st->aux_states[%d]));\n\
|
||||
\t\tfree (st->aux_state[%d]);\n\t}\n%a"
|
||||
idx callee_name callee_name idx
|
||||
idx cp_free_aux (i+1, caller_name)
|
||||
else Format.fprintf fmt "\tif (st->aux_states[%d])\n\
|
||||
\t\tfree(st->aux_states[%d]);\n%a"
|
||||
idx idx cp_free_aux (i+1, caller_name)
|
||||
in
|
||||
|
Loading…
Reference in New Issue
Block a user