summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-03-19 12:48:46 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-19 12:48:54 +0100
commitcd9caf09d1878141871d46a5110648b119b7cb31 (patch)
tree6535c7cc53afc4dbe18026574076c63972d423c2 /lib
parentd3df1b8edaf22101bc7205cb8bb0a661ee3278a2 (diff)
downloadNim-cd9caf09d1878141871d46a5110648b119b7cb31.tar.gz
pcre.nim: added pcre_free and removed hacks in nre and re.nim
Diffstat (limited to 'lib')
-rw-r--r--lib/impure/nre.nim2
-rw-r--r--lib/impure/re.nim7
-rw-r--r--lib/wrappers/pcre.nim2
3 files changed, 5 insertions, 6 deletions
diff --git a/lib/impure/nre.nim b/lib/impure/nre.nim
index 5c5125ba1..823cae1a3 100644
--- a/lib/impure/nre.nim
+++ b/lib/impure/nre.nim
@@ -442,7 +442,7 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:
 # }}}
 
 proc destroyRegex(pattern: Regex) =
-  pcre.free_substring(cast[cstring](pattern.pcreObj))
+  pcre.free(pattern.pcreObj)
   pattern.pcreObj = nil
   if pattern.pcreExtra != nil:
     pcre.free_study(pattern.pcreExtra)
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index 4f32cd5fb..6f57185e6 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -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.
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
index c4bb24cfd..b7975abb8 100644
--- a/lib/wrappers/pcre.nim
+++ b/lib/wrappers/pcre.nim
@@ -341,6 +341,8 @@ proc compile2*(pattern: cstring,
                erroffset: ptr cint,
                tableptr: pointer): ptr Pcre
 
+proc free*(p: ptr Pcre)
+
 proc config*(what: cint,
              where: pointer): cint