1 #include <sys/types.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 5 #include "regex.h" 6 #include "regex2.h" 7 8 /* 9 - regfree - free everything 10 */ 11 void regfree(preg)12regfree(preg) 13 regex_t *preg; 14 { 15 struct re_guts *g; 16 17 if (preg->re_magic != MAGIC1) /* oops */ 18 return; /* nice to complain, but hard */ 19 20 g = preg->re_g; 21 if (g == NULL || g->magic != MAGIC2) /* oops again */ 22 return; 23 preg->re_magic = 0; /* mark it invalid */ 24 g->magic = 0; /* mark it invalid */ 25 26 if (g->strip != NULL) 27 free((char *)g->strip); 28 if (g->sets != NULL) 29 free((char *)g->sets); 30 if (g->setbits != NULL) 31 free((char *)g->setbits); 32 if (g->must != NULL) 33 free(g->must); 34 free((char *)g); 35 } 36