diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-11-07 13:46:12 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-11-07 13:46:12 +0200 |
commit | ac4200fa46eebfc9227130739ae7f867e3fd0a20 (patch) | |
tree | dcfda4ae2e86aba36ea5b34296fb5972dd715ebd | |
parent | 29aae24c51c9682a789c09e37e631b886affcbf7 (diff) | |
download | vmod-binlog-ac4200fa46eebfc9227130739ae7f867e3fd0a20.tar.gz vmod-binlog-ac4200fa46eebfc9227130739ae7f867e3fd0a20.tar.bz2 |
Fix interval initialization from the module_init function.
* doc/vmod-binlog.3: Update.
* src/binlogsel.c (interval) <name>: Remove const.
(interval_add): duplicate the name.
* src/xalloc.c (xstrdup): New function.
* src/xalloc.h: Likewise.
-rw-r--r-- | doc/vmod-binlog.3 | 8 | ||||
-rw-r--r-- | src/binlogsel.c | 4 | ||||
-rw-r--r-- | src/xalloc.c | 5 | ||||
-rw-r--r-- | src/xalloc.h | 1 |
4 files changed, 12 insertions, 6 deletions
diff --git a/doc/vmod-binlog.3 b/doc/vmod-binlog.3 index 42dcccc..7f66dea 100644 --- a/doc/vmod-binlog.3 +++ b/doc/vmod-binlog.3 @@ -10,13 +10,13 @@ .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. -.TH VMOD-BINLOG 1 "October 22, 2013" "VMOD-BINLOG" "User Reference" +.TH VMOD-BINLOG 1 "October 23, 2013" "VMOD-BINLOG" "User Reference" .SH NAME vmod\-binlog \- binary log file support for Varnish Cache. .SH SYNOPSIS .B import binlog; .BI "VOID binlog.init(STRING " dir ", STRING " format ", STRING " param ");" @@ -166,13 +166,13 @@ writes the record to the log file. For example, consider the format specification .PP .EX L Z256 .EE .PP -(i.e. a 32-bit unsigned long value, followed by a string of up to 256 +(i.e. a 32-bit unsigned long value, followed by a string of up to 255 characters). Given this, the following sequence of \fBVCL\fR commands can be used to construct the log entry from the HTTP headers: .PP .EX binlog.start(); binlog.pack(http.X-Id); @@ -185,15 +185,15 @@ specifiers, optionally separated by any amount of whitespace. A conversion specifier consists of a template letter optionally followed by numeric repeat count (which may be enclosed in square brackets). .PP The valid template letters are: .TP -.BI Z [N] +.BI Z[ N ] A null-terminated (ASCIZ) string of at most N-1 characters, will be -null padded. This letter must be followed by repeat count. +null padded. The repeat count is mandatory. .TP .B c A signed char (8-bit) value. .TP .B s A signed short (16-bit) value. diff --git a/src/binlogsel.c b/src/binlogsel.c index 547b4ec..80f5b83 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -65,26 +65,26 @@ time_t start_time, to_time; static int matchnames(const char *dir, const char *pat, glob_t *gl); void selglob(const char *dir, const char *pattern); struct interval { struct interval *next; - const char *name; + char *name; int timemask; time_t start; time_t end; }; static struct interval *interval_head, *interval_tail; void interval_add(const char *name, int tmask, time_t start, time_t end) { struct interval *p = xmalloc(sizeof(*p)); p->next = NULL; - p->name = name; + p->name = xstrdup(name); p->timemask = tmask; p->start = start; p->end = end; if (interval_tail) interval_tail->next = p; else diff --git a/src/xalloc.c b/src/xalloc.c index d12a04c..6ab6802 100644 --- a/src/xalloc.c +++ b/src/xalloc.c @@ -46,8 +46,13 @@ xcalloc(size_t count, size_t size) void * xmemdup(void const *p, size_t s) { return memcpy(xmalloc(s), p, s); } +char * +xstrdup(const char *s) +{ + return xmemdup(s, strlen(s) + 1); +} diff --git a/src/xalloc.h b/src/xalloc.h index da7922f..eb49573 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -1,3 +1,4 @@ void *xmalloc(size_t s); void *xmemdup(void const *p, size_t s); void *xcalloc(size_t count, size_t size); +char *xstrdup(const char *s); |