2
* mem.c - memory allocation checkers
3
* Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
29
static void check(void *p)
32
fatal_error("out of memory");
35
void *ccalloc(size_t n, size_t size)
37
void *mem = calloc(n, size);
43
void *crealloc(void *ptr, size_t new_size)
45
ptr = realloc(ptr, new_size);
51
char *cstrdup(const char *s)
53
char *str = strdup(s);
58
char *casprintf(const char *fmt, ...)
64
if (vasprintf(&str, fmt, ap) < 0)