diff options
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 |