regfree -- Free Memory for Regular Expression

Format

#include <regex.h>
void regfree(regex_t *preg);

Language Level: POSIX, XPG4
regfree frees any memory that was allocated by regcomp to implement the regular expression preg. After the call to regfree, the expression defined by preg is no longer a compiled regular or extended expression.

Return Value
There is no return value.

Example
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.
   ************************************************************/
}



Regular Expressions


regcomp -- Compile Regular Expression
regerror -- Return Error Message for Regular Expression
regexec -- Execute Compiled Regular Expression
<regex.h>