MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
regfree.c
1 #include <my_global.h>
2 #include <sys/types.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include "my_regex.h"
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 my_regfree(preg)
16 my_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 }