Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | |||
7 | #include "utils.h" |
||
8 | #include "regex2.h" |
||
9 | |||
10 | /* |
||
11 | - regfree - free everything |
||
12 | = extern void regfree(regex_t *); |
||
13 | */ |
||
14 | void |
||
15 | regfree(preg) |
||
16 | regex_t *preg; |
||
17 | { |
||
18 | register struct re_guts *g; |
||
19 | |||
20 | if (preg->re_magic != MAGIC1) /* oops */ |
||
21 | return; /* nice to complain, but hard */ |
||
22 | |||
23 | g = preg->re_g; |
||
24 | if (g == NULL || g->magic != MAGIC2) /* oops again */ |
||
25 | return; |
||
26 | preg->re_magic = 0; /* mark it invalid */ |
||
27 | g->magic = 0; /* mark it invalid */ |
||
28 | |||
29 | if (g->strip != NULL) |
||
30 | free((char *)g->strip); |
||
31 | if (g->sets != NULL) |
||
32 | free((char *)g->sets); |
||
33 | if (g->setbits != NULL) |
||
34 | free((char *)g->setbits); |
||
35 | if (g->must != NULL) |
||
36 | free(g->must); |
||
37 | free((char *)g); |
||
38 | } |