1*55852Sbostic /*- 2*55852Sbostic * Copyright (c) 1992 Henry Spencer. 3*55852Sbostic * Copyright (c) 1992 The Regents of the University of California. 4*55852Sbostic * All rights reserved. 5*55852Sbostic * 6*55852Sbostic * This code is derived from software contributed to Berkeley by 7*55852Sbostic * Henry Spencer of the University of Toronto. 8*55852Sbostic * 9*55852Sbostic * %sccs.include.redist.c% 10*55852Sbostic * 11*55852Sbostic * @(#)regfree.c 5.1 (Berkeley) 08/06/92 12*55852Sbostic */ 13*55852Sbostic 14*55852Sbostic #if defined(LIBC_SCCS) && !defined(lint) 15*55852Sbostic static char sccsid[] = "@(#)regfree.c 5.1 (Berkeley) 08/06/92"; 16*55852Sbostic #endif /* LIBC_SCCS and not lint */ 17*55852Sbostic 18*55852Sbostic #include <sys/types.h> 19*55852Sbostic 20*55852Sbostic #include <stdio.h> 21*55852Sbostic #include <stdlib.h> 22*55852Sbostic #include <regex.h> 23*55852Sbostic 24*55852Sbostic #include "utils.h" 25*55852Sbostic #include "regex2.h" 26*55852Sbostic 27*55852Sbostic /* 28*55852Sbostic - regfree - free everything 29*55852Sbostic */ 30*55852Sbostic void 31*55852Sbostic regfree(preg) 32*55852Sbostic regex_t *preg; 33*55852Sbostic { 34*55852Sbostic register struct re_guts *g; 35*55852Sbostic 36*55852Sbostic if (preg->re_magic != MAGIC1) /* oops */ 37*55852Sbostic return; /* nice to complain, but hard */ 38*55852Sbostic 39*55852Sbostic g = preg->re_g; 40*55852Sbostic if (g == NULL || g->magic != MAGIC2) /* oops again */ 41*55852Sbostic return; 42*55852Sbostic preg->re_magic = 0; /* mark it invalid */ 43*55852Sbostic g->magic = 0; /* mark it invalid */ 44*55852Sbostic 45*55852Sbostic if (g->strip != NULL) 46*55852Sbostic free((char *)g->strip); 47*55852Sbostic if (g->sets != NULL) 48*55852Sbostic free((char *)g->sets); 49*55852Sbostic if (g->setbits != NULL) 50*55852Sbostic free((char *)g->setbits); 51*55852Sbostic if (g->must != NULL) 52*55852Sbostic free((char *)g->must); 53*55852Sbostic } 54