From c57844b08bced71778f38f2346464c3e0836287c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 1 Nov 2019 22:06:40 +0100 Subject: Add some functions and add functions with _failed suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- malloc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 malloc.c (limited to 'malloc.c') diff --git a/malloc.c b/malloc.c new file mode 100644 index 0000000..4d40572 --- /dev/null +++ b/malloc.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +void +liberror_malloc_failed(size_t n) +{ + liberror_set_error_errno("Out of memory", "malloc", ENOMEM); + errno = ENOMEM; + (void) n; +} + + +void * +liberror_malloc(size_t n) +{ + void *ret = malloc(n); + if (ret || !n) + return ret; + liberror_save_backtrace(NULL); + liberror_malloc_failed(n); + return NULL; +} -- cgit v1.2.3-70-g09d2