diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binlog.c | 10 | ||||
-rw-r--r-- | src/binlogsel.c | 2 | ||||
-rw-r--r-- | src/pack.c | 25 | ||||
-rw-r--r-- | src/pack.h | 1 |
4 files changed, 34 insertions, 4 deletions
diff --git a/src/binlog.c b/src/binlog.c index 4c3f40e..45299f2 100644 --- a/src/binlog.c +++ b/src/binlog.c @@ -1,5 +1,5 @@ /* This file is part of vmod-binlog - Copyright (C) 2013 Sergey Poznyakoff + Copyright (C) 2013, 2014 Sergey Poznyakoff Vmod-binlog is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,6 +72,7 @@ struct binlog_env { enum binlog_state state; /* binlog machine state */ struct binlog_config *conf; time_t timestamp; /* timestamp for the entry being built */ + struct packinst *inst_head; /* compiled format */ struct packinst *inst_cur; /* current instruction */ struct packenv *env; /* pack environment */ }; @@ -121,12 +122,14 @@ void binlog_env_init(struct binlog_env *ep, struct binlog_config *conf, time_t ts) { if (!ep->env) { - ep->env = packenv_create(packsize(conf->inst_head)); + ep->inst_head = packdup(conf->inst_head); + AN(ep->inst_head); + ep->env = packenv_create(packsize(ep->inst_head)); AN(ep->env); } packenv_init(ep->env); ep->state = state_start; - ep->inst_cur = packinit(conf->inst_head); + ep->inst_cur = packinit(ep->inst_head); ep->timestamp = ts; } @@ -247,6 +250,7 @@ static void env_free(void *f) { struct binlog_env *ep = f; + packfree(ep->inst_head); packenv_free(ep->env); free(ep); } diff --git a/src/binlogsel.c b/src/binlogsel.c index fad0881..da04636 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -1,5 +1,5 @@ /* This file is part of vmod-binlog - Copyright (C) 2013 Sergey Poznyakoff + Copyright (C) 2013, 2014 Sergey Poznyakoff Vmod-binlog is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -714,6 +714,31 @@ packcomp(const char *s, char **endp) return head; } +struct packinst * +packdup(struct packinst *src) +{ + struct packinst *head = NULL, *tail = NULL, *p; + + for (; src; src = src->next) { + p = malloc(sizeof(*p)); + if (!p) { + packfree(head); + errno = ENOMEM; + return NULL; + } + p->next = NULL; + p->spec = src->spec; + p->rep = src->rep; + p->cur = src->cur; + if (tail) + tail->next = p; + else + head = p; + tail = p; + } + return head; +} + void packfree(struct packinst *pi) { @@ -29,6 +29,7 @@ struct packenv { struct packinst; struct packinst *packcomp(const char *s, char **endp); +struct packinst *packdup(struct packinst *s); void packfree(struct packinst *pi); struct packinst *packinit(struct packinst *pi); void packin(struct packinst *pi, struct packenv *env); |