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 del_tracker(struct tracker_list
**list
, int owner
, const char *name
,
41 FOR_EACH_PTR(*list
, tmp
) {
42 if (tmp
->owner
== owner
&& tmp
->sym
== sym
43 && !strcmp(tmp
->name
, name
)) {
44 DELETE_CURRENT_PTR(tmp
);
48 } END_FOR_EACH_PTR(tmp
);
51 int in_tracker_list(struct tracker_list
*list
, int owner
, const char *name
,
56 FOR_EACH_PTR(list
, tmp
) {
57 if (tmp
->owner
== owner
&& tmp
->sym
== sym
58 && !strcmp(tmp
->name
, name
))
60 } END_FOR_EACH_PTR(tmp
);
64 void free_tracker_list(struct tracker_list
**list
)
66 __free_ptr_list((struct ptr_list
**)list
);
69 void free_trackers_and_list(struct tracker_list
**list
)
73 FOR_EACH_PTR(*list
, tmp
) {
74 free_string(tmp
->name
);
76 } END_FOR_EACH_PTR(tmp
);
77 free_tracker_list(list
);