diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-10 12:30:43 -0500 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-10 12:30:43 -0500 |
commit | ca4cf242991ca46fea9cd94afe8207b8bb8fe2f1 (patch) | |
tree | 8a273babd86dd44669056ee5cf0566df409d60df /src/nre.nim | |
parent | 00b047a6600b53a6439e9bf78d05894c5dd10297 (diff) | |
download | Nim-ca4cf242991ca46fea9cd94afe8207b8bb8fe2f1.tar.gz |
Implement correct destruction
Diffstat (limited to 'src/nre.nim')
-rw-r--r-- | src/nre.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nre.nim b/src/nre.nim index 3f06d33bb..2611ee7f6 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -78,8 +78,14 @@ type StudyError* = ref object of Exception +proc destroyRegex(self: Regex) = + pcre.free_substring(cast[cstring](self.pcreObj)) + self.pcreObj = nil + if self.pcreExtra != nil: + pcre.free_study(self.pcreExtra) + proc initRegex*(pattern: string, options = "Sx"): Regex = - new result + new(result, destroyRegex) result.pattern = pattern var errorMsg: cstring @@ -131,3 +137,6 @@ proc getNameToNumberTable(self: Regex): Table[string, int] = idx += 1 result[name] = num + +proc exec*(self: Regex, str: string): RegexMatch = + discard |