diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-18 08:51:53 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-18 08:51:53 +0300 |
commit | dc19c0288af974dd861d61478804b1d7543730be (patch) | |
tree | d211e287444816ed0c034717fdf694928e6d5625 | |
parent | 7b1b68c8a1c65ef33c39f494275eab91b6343658 (diff) | |
download | vmod-dbrw-dc19c0288af974dd861d61478804b1d7543730be.tar.gz vmod-dbrw-dc19c0288af974dd861d61478804b1d7543730be.tar.bz2 |
Remove leftover static data.
* src/dbrw.h (dbrw_connection) <matches,matchsize>: New members.
* src/vmod_dbrw.c (matches,matchsize): Remove static data.
(findmatch): Update accrodingly.
-rw-r--r-- | src/dbrw.h | 9 | ||||
-rw-r--r-- | src/vmod_dbrw.c | 20 |
2 files changed, 15 insertions, 14 deletions
@@ -19,6 +19,7 @@ #include <string.h> #include <errno.h> #include <syslog.h> +#include <regex.h> struct dbrw_connection; @@ -59,9 +60,11 @@ struct dbrw_config { }; struct dbrw_connection { - int state; - struct dbrw_config *conf; - void *data; + int state; /* Connection state */ + struct dbrw_config *conf; /* Pointer to the configuration data */ + regmatch_t *matches; /* Match map */ + size_t matchsize; /* Total number of entries in match map */ + void *data; /* Backend-specific data */ }; void dbrw_debug(const char *fmt, ...); diff --git a/src/vmod_dbrw.c b/src/vmod_dbrw.c index 56a4144..4e7b0e2 100644 --- a/src/vmod_dbrw.c +++ b/src/vmod_dbrw.c @@ -16,7 +16,6 @@ */ #include "dbrw.h" #include <stdarg.h> -#include <regex.h> #include "wordsplit.h" #include "vrt.h" #include "vcc_if.h" @@ -334,9 +333,6 @@ expand_backref(struct sess *sp, const char *str, const char *val, return b; } -static regmatch_t *matches; /* Match map */ -static size_t matchsize; /* Total number of entries in matches */ - #define ISEMPTY(s) ((s) == NULL || (s)[0] == 0) static char * @@ -431,24 +427,24 @@ findmatch(struct sess *sp, struct dbrw_connection *conn, char **param) } matchcount = re.re_nsub + 1; - if (matchsize < matchcount) { - void *p = realloc(matches, - sizeof(matches[0]) * matchcount); + if (conn->matchsize < matchcount) { + void *p = realloc(conn->matches, + sizeof(conn->matches[0]) * matchcount); if (!p) { dbrw_error("not enough memory"); regfree(&re); continue; } - matches = p; - matchsize = matchcount; + conn->matches = p; + conn->matchsize = matchcount; } - rc = regexec(&re, val, matchcount, matches, 0); + rc = regexec(&re, val, matchcount, conn->matches, 0); if (rc == 0) res = expand_backref(sp, val, sql_get_column(conn, i, 0), - matchcount, matches, qry); + matchcount, conn->matches, qry); regfree(&re); if (rc == 0) { @@ -483,6 +479,8 @@ get_connection(struct dbrw_config *conf) cp->state = state_init; cp->conf = conf; cp->data = NULL; + cp->matches = NULL; + cp->matchsize = 0; if (sql_init(cp)) { free(cp); |