diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2006-01-12 04:24:02 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2006-01-12 04:24:02 +0000 |
commit | aeb110d90df145ac99009c1a7b9e3077d6b457a6 (patch) | |
tree | 165a254743e0bdc143eabbd74520a4e90f93a9e1 /regex/regfree.c |
Initial revision
Diffstat (limited to 'regex/regfree.c')
-rw-r--r-- | regex/regfree.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/regex/regfree.c b/regex/regfree.c new file mode 100644 index 0000000..bfcde53 --- /dev/null +++ b/regex/regfree.c @@ -0,0 +1,37 @@ +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <regex.h> + +#include "utils.h" +#include "regex2.h" + +/* + - regfree - free everything + = extern void notbuiltin_regfree(regex_t *); + */ +void +notbuiltin_regfree(preg) +regex_t *preg; +{ + register 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); +} |