Changeset 1651 for zzuf


Ignore:
Timestamp:
Jan 11, 2007, 11:11:56 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Remove two useless malloc() calls.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/fd.c

    r1621 r1651  
    3232
    3333/* Regex stuff */
    34 static regex_t * re_include = NULL;
    35 static regex_t * re_exclude = NULL;
     34static regex_t re_include, re_exclude;
     35static int has_include = 0, has_exclude = 0;
    3636
    3737/* File descriptor stuff */
     
    5050void _zz_include(char const *regex)
    5151{
    52     re_include = malloc(sizeof(*re_include));
    53 
    54     if(regcomp(re_include, regex, REG_EXTENDED) != 0)
    55     {
    56         free(re_include);
    57         re_include = NULL;
    58     }
     52    if(regcomp(&re_include, regex, REG_EXTENDED) == 0)
     53        has_include = 1;
    5954}
    6055
    6156void _zz_exclude(char const *regex)
    6257{
    63     re_exclude = malloc(sizeof(*re_exclude));
    64 
    65     if(regcomp(re_exclude, regex, REG_EXTENDED) != 0)
    66     {
    67         free(re_exclude);
    68         re_exclude = NULL;
    69     }
     58    if(regcomp(&re_exclude, regex, REG_EXTENDED) == 0)
     59        has_exclude = 1;
    7060}
    7161
     
    10090int _zz_mustwatch(char const *file)
    10191{
    102     if(re_include && regexec(re_include, file, 0, NULL, 0) == REG_NOMATCH)
     92    if(has_include && regexec(&re_include, file, 0, NULL, 0) == REG_NOMATCH)
    10393        return 0; /* not included: ignore */
    10494
    105     if(re_exclude && regexec(re_exclude, file, 0, NULL, 0) != REG_NOMATCH)
     95    if(has_exclude && regexec(&re_exclude, file, 0, NULL, 0) != REG_NOMATCH)
    10696        return 0; /* excluded: ignore */
    10797
Note: See TracChangeset for help on using the changeset viewer.