To free any allocated fields of a pattern buffer, use:
void regfree (regex_t *preg)
preg is the pattern buffer whose allocated fields you want freed.
regfree
also sets preg's allocated
and used
fields to zero. After freeing a pattern buffer, you need to again
compile a regular expression in it (see POSIX Regular Expression Compiling) before passing it to the matching function (see POSIX Matching).