Previous: , Up: GNU Regex Functions   [Contents][Index]


18.6.1.9 Freeing GNU Pattern Buffers

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

void
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.