1 : #include <sys/types.h>
2 : #include <stdio.h>
3 : #include <stdlib.h>
4 :
5 : #include "regex.h"
6 : #include "utils.h"
7 : #include "regex2.h"
8 :
9 : /*
10 : - regfree - free everything
11 : = API_EXPORT(void) regfree(regex_t *);
12 : */
13 : API_EXPORT(void)
14 : regfree(preg)
15 : regex_t *preg;
16 415 : {
17 : register struct re_guts *g;
18 :
19 415 : if (preg->re_magic != MAGIC1) /* oops */
20 0 : return; /* nice to complain, but hard */
21 :
22 415 : g = preg->re_g;
23 415 : if (g == NULL || g->magic != MAGIC2) /* oops again */
24 0 : return;
25 415 : preg->re_magic = 0; /* mark it invalid */
26 415 : g->magic = 0; /* mark it invalid */
27 :
28 415 : if (g->strip != NULL)
29 415 : free((char *)g->strip);
30 415 : if (g->sets != NULL)
31 177 : free((char *)g->sets);
32 415 : if (g->setbits != NULL)
33 177 : free((char *)g->setbits);
34 415 : if (g->must != NULL)
35 112 : free(g->must);
36 415 : free((char *)g);
37 : }
|