buf_size: remove the &* and [0] from around the pointer earlier
[smatch.git] / smatch_returns.c
blobc2f6c30a78d44693ede9e5bb35ed09d9049258a8
1 /*
2 * smatch/smatch_returns.c
4 * Copyright (C) 2011 Oracle.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
11 #include "smatch_slist.h"
13 static int my_id;
15 struct return_states_callback {
16 void (*callback)(struct state_list *slist);
18 ALLOCATOR(return_states_callback, "return states callbacks");
19 DECLARE_PTR_LIST(callback_list, struct return_states_callback);
20 static struct callback_list *callback_list;
22 static struct state_list *all_return_states;
24 void all_return_states_hook(void (*callback)(struct state_list *slist))
26 struct return_states_callback *rs_cb = __alloc_return_states_callback(0);
28 rs_cb->callback = callback;
29 add_ptr_list(&callback_list, rs_cb);
32 static void call_hooks()
34 struct return_states_callback *rs_cb;
36 FOR_EACH_PTR(callback_list, rs_cb) {
37 rs_cb->callback(all_return_states);
38 } END_FOR_EACH_PTR(rs_cb);
41 static void match_return(struct expression *ret_value)
43 merge_slist(&all_return_states, __get_cur_slist());
46 static void match_end_func(struct symbol *sym)
48 merge_slist(&all_return_states, __get_cur_slist());
49 call_hooks();
50 free_slist(&all_return_states);
53 void register_returns(int id)
55 my_id = id;
57 add_hook(&match_return, RETURN_HOOK);
58 add_hook(&match_end_func, END_FUNC_HOOK);