]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/regex/regfree.c
fix bug in Borland (bcc32 really hates ?)
[wxWidgets.git] / src / regex / regfree.c
... / ...
CommitLineData
1#ifdef __MWERKS__
2typedef 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 */
17void
18regfree(preg)
19regex_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}