Format
#include <regex.h>
void regfree(regex_t *preg);
Language Level: XPG4
Threadsafe: Yes.
Locale Sensitive: The behavior of this function might be affected by the LC_CTYPE and LC_COLLATE categories of the current locale. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.
Description
The regfree() function frees any memory that was allocated by the regcomp() function to implement the regular expression preg. After the call to the regfree() function, the expression that is defined by preg is no longer a compiled regular or extended expression.
Return Value
There is no return value.
Example that uses regfree()
This example compiles an extended regular expression.
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
regex_t preg;
char *pattern = ".*(simple).*";
int rc;
if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) {
printf("regcomp() failed, returning nonzero (%d)\n", rc);
exit(EXIT_FAILURE);
}
regfree(&preg);
printf("regcomp() is successful.\n");
return 0;
/************************************************************
The output should be similar to:
regcomp() is successful.
************************************************************/
}
Related Information