pcre.nim: added pcre_free and removed hacks in nre and re.nim

This commit is contained in:
Andreas Rumpf 2019-03-19 12:48:46 +01:00
commit cd9caf09d1
3 changed files with 5 additions and 6 deletions

View file

@ -60,12 +60,9 @@ proc rawCompile(pattern: string, flags: cint): ptr Pcre =
raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
proc finalizeRegEx(x: Regex) =
# XXX This is a hack, but PCRE does not export its "free" function properly.
# Sigh. The hack relies on PCRE's implementation (see ``pcre_get.c``).
# Fortunately the implementation is unlikely to change.
pcre.free_substring(cast[cstring](x.h))
pcre.free(x.h)
if not isNil(x.e):
pcre.free_substring(cast[cstring](x.e))
pcre.free_study(x.e)
proc re*(s: string, flags = {reStudy}): Regex =
## Constructor of regular expressions.