ref: f069b33395af1e4a5213b5f5110d583c0af5be7b
parent: b1b28999b0f574f815db036dd1ba8318fb1ec35a
author: Ori Bernstein <[email protected]>
date: Wed Dec 27 06:50:08 EST 2017
Free all matching threads.
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -49,11 +49,11 @@
for var i = 0; i < str.len; i++
thr = run(re, str[i:], 0, false)
m = getmatches(re, thr)
+ cleanup(re)
match m
| `std.Some _: break
| `std.None: /* nothing */
;;
- cleanup(re)
;;
-> m
}
@@ -66,11 +66,11 @@
for var i = 0; i < str.len; i++
thr = run(re, str[i:], 0, false)
m = getidxmatches(re, thr)
+ cleanup(re)
match m
| `std.Some _: break
| `std.None: /* nothing */
;;
- cleanup(re)
;;
-> m
}
@@ -180,6 +180,7 @@
if thr == Zthr
-> `std.None
;;
+
ret = std.slalloc(re.nmatch)
for var i = 0; i < re.nmatch; i++
if thr.mgroup[i][0] != -1 && thr.mgroup[i][1] != -1
@@ -189,6 +190,7 @@
;;
;;
thrfree(re, thr)
+
-> `std.Some ret
}
@@ -269,6 +271,8 @@
goto done
elif !wholestr
bestmatch = thr
+ else
+ thrfree(re, thr)
;;
elif !thr.matched
std.bsput(states, thr.ip)
@@ -446,17 +450,15 @@
var thr : rethread#
thr = std.alloc()
-
thr.next = Zthr
-
thr.ip = ip
thr.tid = re.nexttid++
thr.dead = false
thr.matched = false
-
thr.mgroup = [][:]
-
re.nthr++
+
+ trace(re, thr, "\tcreated {}", thr.tid)
-> thr
}