2 * sparse/smatch_tracker.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
12 ALLOCATOR(tracker
, "trackers");
14 struct tracker
*alloc_tracker(int owner
, const char *name
, struct symbol
*sym
)
18 tmp
= __alloc_tracker(0);
19 tmp
->name
= alloc_string(name
);
25 void add_tracker(struct tracker_list
**list
, int owner
, const char *name
,
30 if (in_tracker_list(*list
, owner
, name
, sym
))
32 tmp
= alloc_tracker(owner
, name
, sym
);
33 add_ptr_list(list
, tmp
);
36 void add_tracker_expr(struct tracker_list
**list
, int owner
, struct expression
*expr
)
41 name
= get_variable_from_expr(expr
, &sym
);
44 add_tracker(list
, owner
, name
, sym
);
49 static void free_tracker(struct tracker
*t
)
56 void del_tracker(struct tracker_list
**list
, int owner
, const char *name
,
61 FOR_EACH_PTR(*list
, tmp
) {
62 if (tmp
->owner
== owner
&& tmp
->sym
== sym
63 && !strcmp(tmp
->name
, name
)) {
64 DELETE_CURRENT_PTR(tmp
);
68 } END_FOR_EACH_PTR(tmp
);
71 int in_tracker_list(struct tracker_list
*list
, int owner
, const char *name
,
76 FOR_EACH_PTR(list
, tmp
) {
77 if (tmp
->owner
== owner
&& tmp
->sym
== sym
78 && !strcmp(tmp
->name
, name
))
80 } END_FOR_EACH_PTR(tmp
);
84 void free_tracker_list(struct tracker_list
**list
)
86 __free_ptr_list((struct ptr_list
**)list
);
89 void free_trackers_and_list(struct tracker_list
**list
)
93 FOR_EACH_PTR(*list
, tmp
) {
95 } END_FOR_EACH_PTR(tmp
);
96 free_tracker_list(list
);