From f035194d7d1b6cc0846ad7a5d86e0d6fa9463c67 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 14 Oct 2013 15:28:51 +0300 Subject: 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. --- src/xalloc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/xalloc.c (limited to 'src/xalloc.c') diff --git a/src/xalloc.c b/src/xalloc.c new file mode 100644 index 0000000..d12a04c --- /dev/null +++ b/src/xalloc.c @@ -0,0 +1,53 @@ +/* This file is part of vmod-binlog + Copyright (C) 2013 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 + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Vmod-binlog is distributed in the hope that it will be useful, + 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 . +*/ + +#include +#include +#include +#include "xalloc.h" +#include "err.h" + +void * +xmalloc(size_t s) +{ + void *p = malloc(s); + if (!p) { + error("out of memory"); + exit(1); + } + return p; +} + +void * +xcalloc(size_t count, size_t size) +{ + void *p; + + size *= count; + p = xmalloc(count * size); + memset(p, 0, size); + return p; +} + +void * +xmemdup(void const *p, size_t s) +{ + return memcpy(xmalloc(s), p, s); +} + + + -- cgit v1.2.1