allocate and free a regex_t
This commit is contained in:
parent
421805e990
commit
19cff62a01
6
main.cc
6
main.cc
@ -23,8 +23,8 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
static const char pattern[] = "\\<Foo\\d";
|
static const char pattern[] = "\\<Foo\\d";
|
||||||
OnigErrorInfo einfo;
|
OnigErrorInfo einfo;
|
||||||
regex_t regex;
|
regex_t * regex;
|
||||||
rc = onig_new_without_alloc(®ex, (const OnigUChar *)pattern,
|
rc = onig_new(®ex, (const OnigUChar *)pattern,
|
||||||
(const OnigUChar *)(pattern + strlen(pattern)), ONIG_OPTION_NONE,
|
(const OnigUChar *)(pattern + strlen(pattern)), ONIG_OPTION_NONE,
|
||||||
ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo);
|
ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo);
|
||||||
if (rc != ONIG_NORMAL)
|
if (rc != ONIG_NORMAL)
|
||||||
@ -35,5 +35,7 @@ int main(int argc, char * argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onig_free(regex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user