From 893ef8be9f45dd692c68d41339f2da7a26431833 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 20 Apr 2014 20:06:04 -0600 Subject: regexec.c: Eliminate a malloc/free This uses an C automatic variable instead of a malloc and free. --- regexec.c | 9 ++++----- 1 file 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); -- cgit v1.2.1