diff options
author | Karl Williamson <khw@cpan.org> | 2014-04-20 20:06:04 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-05-30 16:18:44 -0600 |
commit | 893ef8be9f45dd692c68d41339f2da7a26431833 (patch) | |
tree | 4169666f8cab611cc33be59775c4937f21c0a348 | |
parent | e505af10ddce33807d15910ef9c22af268de3786 (diff) | |
download | perl-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.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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); |