regfree(3f) - [M_regex] Release storage used by the internal form of
the RE (Regular Expression)
subroutine regfree(this)
type(regex_type), intent(inout) :: this
regfree(3f) frees any dynamically-allocated storage used by the internal form of an RE.
The regfree(3f) function frees any dynamically-allocated storage associated with the compiled RE pointed to by THIS. The remaining regex_type is no longer a valid compiled RE and the effect of supplying it to regexec() or regerror() is undefined.
THIS a compiled regular expression previously allocated using regcomp(3f).
Sample program
program demo_regfree
use M_regex, only: regex_type, regcomp, regexec, regmatch, regfree, regerror
implicit none
integer :: istat
type(regex_type) :: regex
character(len=:),allocatable :: expression
expression= "([0-9\.\-\*\/]+)+"
call regcomp(regex,expression,'x')
if (istat/=0) then
stop 'Regex runtime error: regcomp failed.'
endif
call regfree(regex)
end program demo_regfree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(regex_type), | intent(inout) | :: | this |
subroutine regfree(this) ! ident_5="@(#) M_exec regfree(3f) release storage created by regcomp(3f) compiled regular expression" type(regex_type), intent(inout) :: this interface subroutine C_regfree(preg) bind(C,name="regfree") import type(C_ptr), intent(in), value :: preg end subroutine C_regfree end interface call C_regfree(this%preg) this%preg = C_NULL_ptr end subroutine regfree