File: regfree.c

package info (click to toggle)
mysql-5.7 5.7.26-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 484,864 kB
  • sloc: cpp: 2,358,410; ansic: 541,419; pascal: 59,308; perl: 28,135; yacc: 14,261; sql: 7,085; sh: 5,389; xml: 5,365; makefile: 857; lex: 759; python: 675; java: 111; lisp: 89
file content (38 lines) | stat: -rw-r--r-- 744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <my_global.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "my_regex.h"

#include "utils.h"
#include "regex2.h"

/*
 - regfree - free everything
 = extern void regfree(regex_t *);
 */
void
my_regfree(preg)
my_regex_t *preg;
{
	struct re_guts *g;

	if (preg->re_magic != MAGIC1)	/* oops */
		return;			/* nice to complain, but hard */

	g = preg->re_g;
	if (g == NULL || g->magic != MAGIC2)	/* oops again */
		return;
	preg->re_magic = 0;		/* mark it invalid */
	g->magic = 0;			/* mark it invalid */

	if (g->strip != NULL)
		free((char *)g->strip);
	if (g->sets != NULL)
		free((char *)g->sets);
	if (g->setbits != NULL)
		free((char *)g->setbits);
	if (g->must != NULL)
		free(g->must);
	free((char *)g);
}