Previous: Using Registers, Up: GNU Regex Functions Freeing GNU Pattern Buffers

To free any allocated fields of a pattern buffer, use the posix function regfree:

     regfree (regex_t *preg)

preg is the pattern buffer whose allocated fields you want freed; this works because since the type regex_t—the type for posix pattern buffers—is equivalent to the type re_pattern_buffer.

regfree also sets preg's allocated field to zero. After a buffer has been freed, it must have a regular expression compiled in it before passing it to a matching or searching function.