regfree() — Free memory for regular expression
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
Format
#include <regex.h>
void regfree(regex_t *preg);
General description
Frees any memory that was allocated by regcomp() to implement preg. The expression defined by preg is no longer a compiled regular or extended expression. (For a description of regular expressions, see Regular expressions.)
Example
CELEBR10
/* CELEBR10
This example compiles an extended regular expression and a
free regular expression.
*/
#include <regex.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
main() {
regex_t preg;
char *pattern = ".*(simple).*";
int rc;
if ((rc = regcomp(&preg, pattern, REG_EXTENDED)) != 0) {
printf("regcomp() failed, returning nonzero (%d)\n", rc);
exit(1);
}
regfree(&preg);
}
Related information
- Topics about internationalization in z/OS XL C/C++ Programming Guide
- regex.h
- regcomp() — Compile regular expression
- regerror() — Return error message
- regexec() — Execute compiled regular expression