aboutsummaryrefslogtreecommitdiffstats
path: root/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-03-19 03:42:56 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-03-19 03:42:56 +0530
commitdbf60734ba3d540a017081cebcfef901498c0aea (patch)
tree84d957512e3dcbc559be1a7bf6c2850a6404bb47 /nnn.c
parent7e099c2d53f1c711e45e00911f48314b4609c5f8 (diff)
downloadnnn-dbf60734ba3d540a017081cebcfef901498c0aea.tar.gz
Free regex
Diffstat (limited to 'nnn.c')
-rw-r--r--nnn.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/nnn.c b/nnn.c
index 95a0edc..402ee58 100644
--- a/nnn.c
+++ b/nnn.c
@@ -908,10 +908,13 @@ getmime(const char *file)
for (i = 0; i < len; ++i) {
if (regcomp(&regex, assocs[i].regex, REG_NOSUB | REG_EXTENDED | REG_ICASE) != 0)
continue;
- if (regexec(&regex, file, 0, NULL, 0) == 0)
+ if (regexec(&regex, file, 0, NULL, 0) == 0) {
+ regfree(&regex);
return assocs[i].mime;
+ }
}
+ regfree(&regex);
return NULL;
}
@@ -1080,6 +1083,8 @@ matches(char *fltr)
return -1;
fill(&dents, visible, &re);
+ regfree(&re);
+
qsort(dents, ndents, sizeof(*dents), entrycmp);
return 0;
@@ -2218,6 +2223,7 @@ populate(char *path, char *oldname, char *fltr)
#endif
ndents = dentfill(path, &dents, visible, &re);
+ regfree(&re);
qsort(dents, ndents, sizeof(*dents), entrycmp);
@@ -2228,7 +2234,6 @@ populate(char *path, char *oldname, char *fltr)
/* Find cur from history */
cur = dentfind(dents, oldname, ndents);
- regfree(&re);
return 0;
}