2 * Copyright (C) 2009 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
20 ALLOCATOR(tracker
, "trackers");
22 struct tracker
*alloc_tracker(int owner
, const char *name
, struct symbol
*sym
)
26 tmp
= __alloc_tracker(0);
27 tmp
->name
= alloc_string(name
);
33 void add_tracker(struct tracker_list
**list
, int owner
, const char *name
,
38 if (in_tracker_list(*list
, owner
, name
, sym
))
40 tmp
= alloc_tracker(owner
, name
, sym
);
41 add_ptr_list(list
, tmp
);
44 void add_tracker_expr(struct tracker_list
**list
, int owner
, struct expression
*expr
)
49 name
= expr_to_var_sym(expr
, &sym
);
52 add_tracker(list
, owner
, name
, sym
);
57 static void free_tracker(struct tracker
*t
)
63 void del_tracker(struct tracker_list
**list
, int owner
, const char *name
,
68 FOR_EACH_PTR(*list
, tmp
) {
69 if (tmp
->owner
== owner
&& tmp
->sym
== sym
70 && !strcmp(tmp
->name
, name
)) {
71 DELETE_CURRENT_PTR(tmp
);
75 } END_FOR_EACH_PTR(tmp
);
78 int in_tracker_list(struct tracker_list
*list
, int owner
, const char *name
,
83 FOR_EACH_PTR(list
, tmp
) {
84 if (tmp
->owner
== owner
&& tmp
->sym
== sym
85 && !strcmp(tmp
->name
, name
))
87 } END_FOR_EACH_PTR(tmp
);
91 void free_tracker_list(struct tracker_list
**list
)
93 __free_ptr_list((struct ptr_list
**)list
);
96 void free_trackers_and_list(struct tracker_list
**list
)
100 FOR_EACH_PTR(*list
, tmp
) {
102 } END_FOR_EACH_PTR(tmp
);
103 free_tracker_list(list
);