1*9880d681SAndroid Build Coastguard Worker /*-
2*9880d681SAndroid Build Coastguard Worker * This code is derived from OpenBSD's libc/regex, original license follows:
3*9880d681SAndroid Build Coastguard Worker *
4*9880d681SAndroid Build Coastguard Worker * Copyright (c) 1992, 1993, 1994 Henry Spencer.
5*9880d681SAndroid Build Coastguard Worker * Copyright (c) 1992, 1993, 1994
6*9880d681SAndroid Build Coastguard Worker * The Regents of the University of California. All rights reserved.
7*9880d681SAndroid Build Coastguard Worker *
8*9880d681SAndroid Build Coastguard Worker * This code is derived from software contributed to Berkeley by
9*9880d681SAndroid Build Coastguard Worker * Henry Spencer.
10*9880d681SAndroid Build Coastguard Worker *
11*9880d681SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without
12*9880d681SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions
13*9880d681SAndroid Build Coastguard Worker * are met:
14*9880d681SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright
15*9880d681SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer.
16*9880d681SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright
17*9880d681SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the
18*9880d681SAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution.
19*9880d681SAndroid Build Coastguard Worker * 3. Neither the name of the University nor the names of its contributors
20*9880d681SAndroid Build Coastguard Worker * may be used to endorse or promote products derived from this software
21*9880d681SAndroid Build Coastguard Worker * without specific prior written permission.
22*9880d681SAndroid Build Coastguard Worker *
23*9880d681SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24*9880d681SAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25*9880d681SAndroid Build Coastguard Worker * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26*9880d681SAndroid Build Coastguard Worker * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27*9880d681SAndroid Build Coastguard Worker * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28*9880d681SAndroid Build Coastguard Worker * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29*9880d681SAndroid Build Coastguard Worker * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30*9880d681SAndroid Build Coastguard Worker * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31*9880d681SAndroid Build Coastguard Worker * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32*9880d681SAndroid Build Coastguard Worker * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33*9880d681SAndroid Build Coastguard Worker * SUCH DAMAGE.
34*9880d681SAndroid Build Coastguard Worker *
35*9880d681SAndroid Build Coastguard Worker * @(#)regfree.c 8.3 (Berkeley) 3/20/94
36*9880d681SAndroid Build Coastguard Worker */
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker #include <sys/types.h>
39*9880d681SAndroid Build Coastguard Worker #include <stdio.h>
40*9880d681SAndroid Build Coastguard Worker #include <stdlib.h>
41*9880d681SAndroid Build Coastguard Worker #include "regex_impl.h"
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker #include "regutils.h"
44*9880d681SAndroid Build Coastguard Worker #include "regex2.h"
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker /*
47*9880d681SAndroid Build Coastguard Worker - llvm_regfree - free everything
48*9880d681SAndroid Build Coastguard Worker */
49*9880d681SAndroid Build Coastguard Worker void
llvm_regfree(llvm_regex_t * preg)50*9880d681SAndroid Build Coastguard Worker llvm_regfree(llvm_regex_t *preg)
51*9880d681SAndroid Build Coastguard Worker {
52*9880d681SAndroid Build Coastguard Worker struct re_guts *g;
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker if (preg->re_magic != MAGIC1) /* oops */
55*9880d681SAndroid Build Coastguard Worker return; /* nice to complain, but hard */
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker g = preg->re_g;
58*9880d681SAndroid Build Coastguard Worker if (g == NULL || g->magic != MAGIC2) /* oops again */
59*9880d681SAndroid Build Coastguard Worker return;
60*9880d681SAndroid Build Coastguard Worker preg->re_magic = 0; /* mark it invalid */
61*9880d681SAndroid Build Coastguard Worker g->magic = 0; /* mark it invalid */
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker if (g->strip != NULL)
64*9880d681SAndroid Build Coastguard Worker free((char *)g->strip);
65*9880d681SAndroid Build Coastguard Worker if (g->sets != NULL)
66*9880d681SAndroid Build Coastguard Worker free((char *)g->sets);
67*9880d681SAndroid Build Coastguard Worker if (g->setbits != NULL)
68*9880d681SAndroid Build Coastguard Worker free((char *)g->setbits);
69*9880d681SAndroid Build Coastguard Worker if (g->must != NULL)
70*9880d681SAndroid Build Coastguard Worker free(g->must);
71*9880d681SAndroid Build Coastguard Worker free((char *)g);
72*9880d681SAndroid Build Coastguard Worker }
73