mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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:
parent
e5effa4bd0
commit
7193b404a1
Notes:
git
2023-07-27 17:33:59 +00:00
5 changed files with 185 additions and 191 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue