Plug regex memory leaks - noice - small file browser (mirror / fork from 2f30.org)
 (HTM) git clone git://git.codemadness.org/noice
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit fef811921b50a2e4a3501e4cef47286c855b4727
 (DIR) parent 2f11fc5427127bcfdf84dd4e1c71c5c91157088c
 (HTM) Author: Lazaros Koromilas <lostd@2f30.org>
       Date:   Sun, 25 Feb 2018 12:29:18 +0200
       
       Plug regex memory leaks
       
       Diffstat:
         M noice.c                             |      10 ++++++++++
       
       1 file changed, 10 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/noice.c b/noice.c
       @@ -213,8 +213,10 @@ openwith(char *file)
                                continue;
                        if (regexec(&regex, file, 0, NULL, 0) == 0) {
                                bin = assocs[i].bin;
       +                        regfree(&regex);
                                break;
                        }
       +                regfree(&regex);
                }
                DPRINTF_S(bin);
                return bin;
       @@ -239,6 +241,12 @@ setfilter(regex_t *regex, char *filter)
        }
        
        void
       +freefilter(regex_t *regex)
       +{
       +        regfree(regex);
       +}
       +
       +void
        initfilter(int dot, char **ifilter)
        {
                *ifilter = dot ? "." : "^[^.]";
       @@ -520,6 +528,7 @@ populate(char *path, char *oldpath, char *fltr)
                dents = NULL;
        
                ndents = dentfill(path, &dents, visible, &re);
       +        freefilter(&re);
        
                qsort(dents, ndents, sizeof(*dents), entrycmp);
        
       @@ -677,6 +686,7 @@ nochange:
                                r = setfilter(&re, tmp);
                                if (r != 0)
                                        goto nochange;
       +                        freefilter(&re);
                                strlcpy(fltr, tmp, sizeof(fltr));
                                DPRINTF_S(fltr);
                                /* Save current */