From ff35af3b422d81143cdd436b9412652bca760a69 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 10 Dec 2021 21:11:46 +0100 Subject: Add strdup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- strdup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 strdup.c (limited to 'strdup.c') diff --git a/strdup.c b/strdup.c new file mode 100644 index 0000000..0b1c8ee --- /dev/null +++ b/strdup.c @@ -0,0 +1,22 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +void +liberror_strdup_failed(const char *s) +{ + liberror_set_error_errno(errno == ENOMEM ? "Out of memory" : "", "strdup", errno); + (void) s; +} + + +char * +liberror_strdup(const char *s) +{ + char *ret = malloc(s); + if (ret) + return ret; + liberror_save_backtrace(NULL); + liberror_strdup_failed(s); + return NULL; +} -- cgit v1.2.3-70-g09d2