From f72f3ab15b79d35e3ddc53d7d3df0e75d5402575 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 27 Jul 2023 15:39:05 -0400 Subject: Use onig_new_without_alloc for onig_new --- regcomp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index b2254c26a0..b880c85bf1 100644 --- a/regcomp.c +++ b/regcomp.c @@ -6073,20 +6073,15 @@ onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax, OnigErrorInfo* einfo) { - int r; - *reg = (regex_t* )xmalloc(sizeof(regex_t)); if (IS_NULL(*reg)) return ONIGERR_MEMORY; - r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax); - if (r) goto err; - - r = onig_compile(*reg, pattern, pattern_end, einfo); + int r = onig_new_without_alloc(*reg, pattern, pattern_end, option, enc, syntax, einfo); if (r) { - err: onig_free(*reg); *reg = NULL; } + return r; } -- cgit v1.2.3