diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-14 15:28:51 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-14 17:54:41 +0300 |
commit | f035194d7d1b6cc0846ad7a5d86e0d6fa9463c67 (patch) | |
tree | 494d180cee9a078727c8d4965caa65cb2052f33d /src/binlogcat.c | |
parent | 58f7dbc0658b3d73816a1bc91b75c2bdac733510 (diff) | |
download | vmod-binlog-f035194d7d1b6cc0846ad7a5d86e0d6fa9463c67.tar.gz vmod-binlog-f035194d7d1b6cc0846ad7a5d86e0d6fa9463c67.tar.bz2 |
New utility binlogsel
* configure.ac: Check for yacc.
* src/.gitignore: Update.
* src/Makefile.am (libbinlog_a_SOURCES): Add new files.
Build binlogsel.
* src/binlogcat.c: Use xmalloc.
* src/binlogsel.c: New file.
* src/parse-datetime.h: New file.
* src/parse-datetime.y: New file.
* src/xalloc.c: New file.
* src/xalloc.h: New file.
Diffstat (limited to 'src/binlogcat.c')
-rw-r--r-- | src/binlogcat.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/binlogcat.c b/src/binlogcat.c index 505bbc2..656d8f2 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c @@ -27,6 +27,7 @@ #include "vmod-binlog.h" #include "pack.h" #include "err.h" +#include "xalloc.h" char *timefmt = "%c"; int number_option; @@ -75,11 +76,7 @@ catlog(const char *fname) } size = header.hdrsize - sizeof(header); - dataspec = malloc(size); - if (!dataspec) { - error("not enough memory"); - abort(); - } + dataspec = xmalloc(size); if (fread(dataspec, size, 1, fp) != 1) { error("error reading header of %s: %s", @@ -94,7 +91,7 @@ catlog(const char *fname) inst = packcomp(dataspec, &p); if (!inst) { if (errno == EINVAL) { - error("%s: bad dataspec near %s", dataspec, p); + error("%s: %s: bad dataspec near %s", fname, dataspec, p); exit(1); } @@ -103,11 +100,7 @@ catlog(const char *fname) } free(dataspec); - rec = malloc(header.recsize); - if (!rec) { - error("not enough memory"); - exit(1); - } + rec = xmalloc(header.recsize); env = packenv_create(header.recsize - offsetof(struct binlog_record,data)); env->fp = stdout; @@ -147,7 +140,7 @@ catlog(const char *fname) void help() { - printf("usage: %s [-dhnv] [t FORMAT] [FILE...]\n", progname); + printf("usage: %s [-dhnv] [-t FORMAT] [FILE...]\n", progname); } int |