smatch_implied: only print the nr_children message once.
[smatch.git] / smatch_tracker.c
blobe460b332cf849af2d96279aac86ec15cbd3ebbf5
1 #include "smatch.h"
3 ALLOCATOR(tracker, "trackers");
5 void add_tracker(struct tracker_list **list, const char *name, int owner,
6 struct symbol *sym)
8 struct tracker *tmp;
10 if (in_tracker_list(*list, name, owner, sym))
11 return;
13 tmp = __alloc_tracker(0);
14 tmp->name = alloc_string(name);
15 tmp->owner = owner;
16 tmp->sym = sym;
17 add_ptr_list(list, tmp);
20 void del_tracker(struct tracker_list **list, const char *name, int owner,
21 struct symbol *sym)
23 struct tracker *tmp;
25 FOR_EACH_PTR(*list, tmp) {
26 if (tmp->owner == owner && tmp->sym == sym
27 && !strcmp(tmp->name, name)) {
28 DELETE_CURRENT_PTR(tmp);
29 __free_tracker(tmp);
30 return;
32 } END_FOR_EACH_PTR(tmp);
35 int in_tracker_list(struct tracker_list *list, const char *name, int owner,
36 struct symbol *sym)
38 struct tracker *tmp;
40 FOR_EACH_PTR(list, tmp) {
41 if (tmp->owner == owner && tmp->sym == sym
42 && !strcmp(tmp->name, name))
43 return 1;
44 } END_FOR_EACH_PTR(tmp);
45 return 0;
48 void free_tracker_list(struct tracker_list **list)
50 __free_ptr_list((struct ptr_list **)list);
53 void free_trackers_and_list(struct tracker_list **list)
55 struct tracker *tmp;
57 FOR_EACH_PTR(*list, tmp) {
58 free_string(tmp->name);
59 __free_tracker(tmp);
60 } END_FOR_EACH_PTR(tmp);
61 free_tracker_list(list);