1 /* Authors: Jason Tang <jtang@tresys.com>
2  *
3  * Copyright (C) 2005 Tresys Technology, LLC
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2.1 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #include <sepol/policydb/policydb.h>
21 #include <sepol/policydb/constraint.h>
22 #include <sepol/policydb/expand.h>
23 #include <sepol/policydb/flask_types.h>
24 
25 #include <assert.h>
26 #include <stdlib.h>
27 
constraint_expr_init(constraint_expr_t * expr)28 int constraint_expr_init(constraint_expr_t * expr)
29 {
30 	memset(expr, 0, sizeof(*expr));
31 	ebitmap_init(&expr->names);
32 	if ((expr->type_names = malloc(sizeof(*expr->type_names))) == NULL) {
33 		return -1;
34 	}
35 	type_set_init(expr->type_names);
36 	return 0;
37 }
38 
constraint_expr_destroy(constraint_expr_t * expr)39 void constraint_expr_destroy(constraint_expr_t * expr)
40 {
41 	if (expr != NULL) {
42 		ebitmap_destroy(&expr->names);
43 		type_set_destroy(expr->type_names);
44 		free(expr->type_names);
45 		free(expr);
46 	}
47 }
48