Index: src/garden.h =================================================================== --- a/src/garden.h (revision 492) +++ b/src/garden.h (working copy) @@ -39,13 +39,18 @@ (a)->port == (b)->port) #ifdef ENABLE_CHILLIREDIR +struct chilli_regex { + regex_t re; + char allocated:1; +}; + typedef struct regex_pass_through_t { char regex_host[512]; char regex_path[512]; char regex_qs[512]; - regex_t re_host; - regex_t re_path; - regex_t re_qs; + struct chilli_regex re_host; + struct chilli_regex re_path; + struct chilli_regex re_qs; char inuse:1; char neg_host:1; char neg_path:1; Index: src/main-redir.c =================================================================== --- a/src/main-redir.c (revision 492) +++ b/src/main-redir.c (working copy) @@ -503,7 +503,7 @@ } static int -check_regex(regex_t *re, char *regex, char *s) { +check_regex(struct chilli_regex *re, char *regex, char *s) { int ret; #if(_debug_) @@ -510,22 +510,19 @@ log_dbg("Checking %s =~ %s", s, regex); #endif -#if defined (__FreeBSD__) || defined (__APPLE__) || defined (__OpenBSD__) || defined (__NetBSD__) - if (!re->re_g) -#else - if (!re->allocated) -#endif + if (!re->allocated) { - if ((ret = regcomp(re, regex, REG_EXTENDED | REG_NOSUB)) != 0) { + if ((ret = regcomp(&re->re, regex, REG_EXTENDED | REG_NOSUB)) != 0) { char error[512]; - regerror(ret, re, error, sizeof(error)); + regerror(ret, &re->re, error, sizeof(error)); log_err(0, "regcomp(%s) failed (%s)", regex, error); regex[0] = 0; return -1; } + re->allocated = 1; } - if ((ret = regexec(re, s, 0, 0, 0)) == 0) { + if ((ret = regexec(&re->re, s, 0, 0, 0)) == 0) { log_dbg("Matched regex %s", regex); return 0; Index: src/options.c =================================================================== --- a/src/options.c (revision 492) +++ b/src/options.c (working copy) @@ -373,18 +373,12 @@ #ifdef ENABLE_CHILLIREDIR for (i = 0; i < MAX_REGEX_PASS_THROUGHS; i++) { -#if defined (__FreeBSD__) || defined (__APPLE__) || defined (__OpenBSD__) || defined (__NetBSD__) - regfree(&_options.regex_pass_throughs[i].re_host); - regfree(&_options.regex_pass_throughs[i].re_path); - regfree(&_options.regex_pass_throughs[i].re_qs); -#else if (_options.regex_pass_throughs[i].re_host.allocated) - regfree(&_options.regex_pass_throughs[i].re_host); + regfree(&_options.regex_pass_throughs[i].re_host.re); if (_options.regex_pass_throughs[i].re_path.allocated) - regfree(&_options.regex_pass_throughs[i].re_path); + regfree(&_options.regex_pass_throughs[i].re_path.re); if (_options.regex_pass_throughs[i].re_qs.allocated) - regfree(&_options.regex_pass_throughs[i].re_qs); -#endif + regfree(&_options.regex_pass_throughs[i].re_qs.re); } #endif