summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-04-20 20:06:04 -0600
committerKarl Williamson <khw@cpan.org>2014-05-30 16:18:44 -0600
commit893ef8be9f45dd692c68d41339f2da7a26431833 (patch)
tree4169666f8cab611cc33be59775c4937f21c0a348
parente505af10ddce33807d15910ef9c22af268de3786 (diff)
downloadperl-893ef8be9f45dd692c68d41339f2da7a26431833.tar.gz
regexec.c: Eliminate a malloc/free
This uses an C automatic variable instead of a malloc and free.
-rw-r--r--regexec.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/regexec.c b/regexec.c
index 32c446fd6e..6386d41d06 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7796,20 +7796,19 @@ S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const
SV * const sw = _get_regclass_nonbitmap_data(prog, n, TRUE, 0,
&only_utf8_locale);
if (sw) {
+ U8 utf8_buffer[2];
U8 * utf8_p;
if (utf8_target) {
utf8_p = (U8 *) p;
} else { /* Convert to utf8 */
- STRLEN len = 1;
- utf8_p = bytes_to_utf8(p, &len);
+ utf8_p = utf8_buffer;
+ append_utf8_from_native_byte(*p, &utf8_p);
+ utf8_p = utf8_buffer;
}
if (swash_fetch(sw, utf8_p, TRUE)) {
match = TRUE;
}
-
- /* If we allocated a string above, free it */
- if (! utf8_target) Safefree(utf8_p);
}
if (! match && only_utf8_locale && IN_UTF8_CTYPE_LOCALE) {
match = _invlist_contains_cp(only_utf8_locale, c);