113cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle/* Authors: Jason Tang <jtang@tresys.com>
213cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *
313cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle * Copyright (C) 2005 Tresys Technology, LLC
413cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *
513cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  This library is free software; you can redistribute it and/or
613cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  modify it under the terms of the GNU Lesser General Public
713cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  License as published by the Free Software Foundation; either
813cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  version 2.1 of the License, or (at your option) any later version.
913cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *
1013cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  This library is distributed in the hope that it will be useful,
1113cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  but WITHOUT ANY WARRANTY; without even the implied warranty of
1213cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1313cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  Lesser General Public License for more details.
1413cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *
1513cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  You should have received a copy of the GNU Lesser General Public
1613cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  License along with this library; if not, write to the Free Software
1713cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1813cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle */
1913cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle
2013cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <sepol/policydb/policydb.h>
2113cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <sepol/policydb/constraint.h>
2213cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <sepol/policydb/expand.h>
2313cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <sepol/policydb/flask_types.h>
2413cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle
2513cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <assert.h>
2613cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle#include <stdlib.h>
2713cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle
2813cd4c8960688af11ad23b4c946149015c80d54Joshua Brindleint constraint_expr_init(constraint_expr_t * expr)
2913cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle{
3013cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	memset(expr, 0, sizeof(*expr));
3113cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	ebitmap_init(&expr->names);
3213cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	if ((expr->type_names = malloc(sizeof(*expr->type_names))) == NULL) {
3313cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle		return -1;
3413cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	}
3513cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	type_set_init(expr->type_names);
3613cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	return 0;
3713cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle}
3813cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle
3913cd4c8960688af11ad23b4c946149015c80d54Joshua Brindlevoid constraint_expr_destroy(constraint_expr_t * expr)
4013cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle{
4113cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	if (expr != NULL) {
4213cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle		ebitmap_destroy(&expr->names);
4313cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle		type_set_destroy(expr->type_names);
4413cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle		free(expr->type_names);
4513cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle		free(expr);
4613cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle	}
4713cd4c8960688af11ad23b4c946149015c80d54Joshua Brindle}
48