00001 /*- 00002 * Copyright (c) 1992, 1993, 1994 Henry Spencer. 00003 * Copyright (c) 1992, 1993, 1994 00004 * The Regents of the University of California. All rights reserved. 00005 * 00006 * This code is derived from software contributed to Berkeley by 00007 * Henry Spencer. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 2. Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the distribution. 00017 * 3. All advertising materials mentioning features or use of this software 00018 * must display the following acknowledgement: 00019 * This product includes software developed by the University of 00020 * California, Berkeley and its contributors. 00021 * 4. Neither the name of the University nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00026 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00028 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00031 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00032 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00034 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00035 * SUCH DAMAGE. 00036 * 00037 * @(#)regfree.c 8.3 (Berkeley) 3/20/94 00038 */ 00039 00040 #if defined(LIBC_SCCS) && !defined(lint) 00041 static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; 00042 #endif /* LIBC_SCCS and not lint */ 00043 00044 #include <sys/types.h> 00045 #include <stdio.h> 00046 #include <stdlib.h> 00047 #include "regex.h" 00048 00049 #include "utils.h" 00050 #include "regex2.h" 00051 00052 /* 00053 - regfree - free everything 00054 = extern void regfree(regex_t *); 00055 */ 00056 void __stdcall 00057 regfree(preg) 00058 regex_t *preg; 00059 { 00060 register struct re_guts *g; 00061 00062 if (preg->re_magic != MAGIC1) /* oops */ 00063 return; /* nice to complain, but hard */ 00064 00065 g = preg->re_g; 00066 if (g == NULL || g->magic != MAGIC2) /* oops again */ 00067 return; 00068 preg->re_magic = 0; /* mark it invalid */ 00069 g->magic = 0; /* mark it invalid */ 00070 00071 if (g->strip != NULL) 00072 free((char *)g->strip); 00073 if (g->sets != NULL) 00074 free((char *)g->sets); 00075 if (g->setbits != NULL) 00076 free((char *)g->setbits); 00077 if (g->must != NULL) 00078 free(g->must); 00079 free((char *)g); 00080 }