155852Sbostic /*- 266362Sbostic * Copyright (c) 1992, 1993, 1994 Henry Spencer. 366362Sbostic * Copyright (c) 1992, 1993, 1994 461164Sbostic * The Regents of the University of California. All rights reserved. 555852Sbostic * 655852Sbostic * This code is derived from software contributed to Berkeley by 7*66406Sbostic * Henry Spencer. 855852Sbostic * 955852Sbostic * %sccs.include.redist.c% 1055852Sbostic * 11*66406Sbostic * @(#)regfree.c 8.3 (Berkeley) 03/20/94 1255852Sbostic */ 1355852Sbostic 1455852Sbostic #if defined(LIBC_SCCS) && !defined(lint) 15*66406Sbostic static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 03/20/94"; 1655852Sbostic #endif /* LIBC_SCCS and not lint */ 1755852Sbostic 1855852Sbostic #include <sys/types.h> 1955852Sbostic #include <stdio.h> 2055852Sbostic #include <stdlib.h> 2155852Sbostic #include <regex.h> 2255852Sbostic 2355852Sbostic #include "utils.h" 2455852Sbostic #include "regex2.h" 2555852Sbostic 2655852Sbostic /* 2755852Sbostic - regfree - free everything 2866362Sbostic = extern void regfree(regex_t *); 2955852Sbostic */ 3055852Sbostic void regfree(preg)3155852Sbosticregfree(preg) 3255852Sbostic regex_t *preg; 3355852Sbostic { 3455852Sbostic register struct re_guts *g; 3555852Sbostic 3655852Sbostic if (preg->re_magic != MAGIC1) /* oops */ 3755852Sbostic return; /* nice to complain, but hard */ 3855852Sbostic 3955852Sbostic g = preg->re_g; 4055852Sbostic if (g == NULL || g->magic != MAGIC2) /* oops again */ 4155852Sbostic return; 4255852Sbostic preg->re_magic = 0; /* mark it invalid */ 4355852Sbostic g->magic = 0; /* mark it invalid */ 4455852Sbostic 4555852Sbostic if (g->strip != NULL) 4655852Sbostic free((char *)g->strip); 4755852Sbostic if (g->sets != NULL) 4855852Sbostic free((char *)g->sets); 4955852Sbostic if (g->setbits != NULL) 5055852Sbostic free((char *)g->setbits); 5155852Sbostic if (g->must != NULL) 5260201Sbostic free(g->must); 5360201Sbostic free((char *)g); 5455852Sbostic } 55