From 8aba25a477b91bfae213a8247e364bf4e7cddb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 9 Oct 2020 19:43:04 +0200 Subject: [PATCH] xmalloc: add xwcsdup() --- xmalloc.c | 7 +++++++ xmalloc.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/xmalloc.c b/xmalloc.c index c90b97dc..a9a6685c 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "xmalloc.h" @@ -54,6 +55,12 @@ xstrdup(const char *str) return check_alloc(strdup(str)); } +wchar_t * +xwcsdup(const wchar_t *str) +{ + return check_alloc(wcsdup(str)); +} + char * xstrndup(const char *str, size_t n) { diff --git a/xmalloc.h b/xmalloc.h index 2c12cf0a..13d69ca4 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "macros.h" void *xmalloc(size_t size) XMALLOC; @@ -9,3 +10,4 @@ void *xrealloc(void *ptr, size_t size); char *xstrdup(const char *str) XSTRDUP; char *xstrndup(const char *str, size_t n) XSTRDUP; char *xasprintf(const char *format, ...) PRINTF(1) XMALLOC; +wchar_t *xwcsdup(const wchar_t *str) XSTRDUP;