diff options
Diffstat (limited to 'lib/util/alloc.c')
-rw-r--r-- | lib/util/alloc.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/lib/util/alloc.c b/lib/util/alloc.c deleted file mode 100644 index 526a4d5..0000000 --- a/lib/util/alloc.c +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * alloc.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "util/util.h" - -#include <stddef.h> -#include <stdlib.h> -#include <errno.h> - -void *alloc_flex(size_t base_size, size_t item_size, size_t nmemb) -{ - size_t size; - - if (SZ_MUL_OV(nmemb, item_size, &size) || - SZ_ADD_OV(base_size, size, &size)) { - errno = EOVERFLOW; - return NULL; - } - - return calloc(1, size); -} - -void *alloc_array(size_t item_size, size_t nmemb) -{ - size_t size; - - if (SZ_MUL_OV(nmemb, item_size, &size)) { - errno = EOVERFLOW; - return NULL; - } - - return calloc(1, size); -} |