xref: /illumos-gate/usr/src/tools/smatch/src/smatch_expression_stacks.c (revision 6a817834d81cc75ce12d0d393320837b1fec1e85)
1 /*
2  * Copyright (C) 2009 Dan Carpenter.
3  *
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.
8  *
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.
13  *
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
16  */
17 
18 #include "smatch.h"
19 #include "smatch_expression_stacks.h"
20 
21 void push_expression(struct expression_list **estack, struct expression *expr)
22 {
23 	add_ptr_list(estack, expr);
24 }
25 
26 struct expression *pop_expression(struct expression_list **estack)
27 {
28 	struct expression *expr;
29 
30 	expr = last_ptr_list((struct ptr_list *)*estack);
31 	delete_ptr_list_last((struct ptr_list **)estack);
32 	return expr;
33 }
34 
35 struct expression *top_expression(struct expression_list *estack)
36 {
37 	struct expression *expr;
38 
39 	expr = last_ptr_list((struct ptr_list *)estack);
40 	return expr;
41 }
42 
43 void free_expression_stack(struct expression_list **estack)
44 {
45 	__free_ptr_list((struct ptr_list **)estack);
46 }
47