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