summaryrefslogtreecommitdiff
path: root/sample/posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'sample/posix.c')
-rw-r--r--sample/posix.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sample/posix.c b/sample/posix.c
index 65bcf51..35ccb68 100644
--- a/sample/posix.c
+++ b/sample/posix.c
@@ -16,6 +16,7 @@ static int x(regex_t* reg, unsigned char* pattern, unsigned char* str)
if (r != 0 && r != REG_NOMATCH) {
regerror(r, reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(reg);
return -1;
}
@@ -28,6 +29,7 @@ static int x(regex_t* reg, unsigned char* pattern, unsigned char* str)
fprintf(stderr, "%d: %d-%d\n", i, pmatch[i].rm_so, pmatch[i].rm_eo);
}
}
+ regfree(reg);
return 0;
}
@@ -46,6 +48,7 @@ extern int main(int argc, char* argv[])
if (r) {
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(&reg);
return -1;
}
x(&reg, pattern, (UChar* )"aaabbbbd");
@@ -56,6 +59,7 @@ extern int main(int argc, char* argv[])
if (r) {
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(&reg);
return -1;
}
x(&reg, pattern, (UChar* )"a+b{2,7}d?|uuu");
@@ -66,6 +70,7 @@ extern int main(int argc, char* argv[])
if (r) {
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(&reg);
return -1;
}
x(&reg, pattern, (UChar* )"aaaabbbbbbd");
@@ -77,6 +82,7 @@ extern int main(int argc, char* argv[])
if (r) {
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(&reg);
return -1;
}
x(&reg, pattern, (UChar* )"aaabbbbd)");
@@ -86,11 +92,11 @@ extern int main(int argc, char* argv[])
if (r) {
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
+ regfree(&reg);
return -1;
}
x(&reg, pattern, (UChar* )"a\nb\n");
- regfree(&reg);
onig_end();
return 0;
}