allocate and free a regex_t

This commit is contained in:
Josh Holtrop 2018-03-16 19:15:21 -04:00
parent 421805e990
commit 19cff62a01

View File

@ -23,8 +23,8 @@ int main(int argc, char * argv[])
static const char pattern[] = "\\<Foo\\d";
OnigErrorInfo einfo;
regex_t regex;
rc = onig_new_without_alloc(&regex, (const OnigUChar *)pattern,
regex_t * regex;
rc = onig_new(&regex, (const OnigUChar *)pattern,
(const OnigUChar *)(pattern + strlen(pattern)), ONIG_OPTION_NONE,
ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo);
if (rc != ONIG_NORMAL)
@ -35,5 +35,7 @@ int main(int argc, char * argv[])
return 1;
}
onig_free(regex);
return 0;
}