]> git.saurik.com Git - wxWidgets.git/blob - src/regex/regfree.c
compilation fix for wxUSE_RESOURCE_LOADING_IN_MSW == 0
[wxWidgets.git] / src / regex / regfree.c
1 #ifdef __MWERKS__
2 typedef long off_t ;
3 #else
4 #include <sys/types.h>
5 #endif
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "regex.h"
9
10 #include "utils.h"
11 #include "regex2.h"
12
13 /*
14 - regfree - free everything
15 = extern void regfree(regex_t *);
16 */
17 void
18 regfree(preg)
19 regex_t *preg;
20 {
21 register struct re_guts *g;
22
23 if (preg->re_magic != MAGIC1) /* oops */
24 return; /* nice to complain, but hard */
25
26 g = preg->re_g;
27 if (g == NULL || g->magic != MAGIC2) /* oops again */
28 return;
29 preg->re_magic = 0; /* mark it invalid */
30 g->magic = 0; /* mark it invalid */
31
32 if (g->strip != NULL)
33 free((char *)g->strip);
34 if (g->sets != NULL)
35 free((char *)g->sets);
36 if (g->setbits != NULL)
37 free((char *)g->setbits);
38 if (g->must != NULL)
39 free(g->must);
40 free((char *)g);
41 }