Add function rb_reg_onig_match

rb_reg_onig_match performs preparation, error handling, and cleanup for
matching a regex against a string. This reduces repetitive code and
removes the need for StringScanner to access internal data of regex.
This commit is contained in:
Peter Zhu 2023-07-26 15:57:03 -04:00
parent e5effa4bd0
commit 7193b404a1
Notes: git 2023-07-27 17:33:59 +00:00
5 changed files with 185 additions and 191 deletions

View file

@ -888,12 +888,16 @@ onig_region_free(OnigRegion* r, int free_self)
if (r->allocated > 0) {
xfree(r->beg);
xfree(r->end);
r->allocated = 0;
}
#ifdef USE_CAPTURE_HISTORY
history_root_free(r);
#endif
if (free_self) xfree(r);
if (free_self) {
xfree(r);
}
else {
memset(r, 0, sizeof(OnigRegion));
}
}
}