From d8ccc87fed8a4c588e4ad9279e62925f416d36b3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 25 Nov 2018 23:05:59 +0100 Subject: Some fixes and add wide-character string duplication functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- enwcsdup.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 enwcsdup.c (limited to 'enwcsdup.c') diff --git a/enwcsdup.c b/enwcsdup.c new file mode 100644 index 0000000..d9edbb0 --- /dev/null +++ b/enwcsdup.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enwcsdup(int status, const wchar_t *s) /* TODO test */ +{ + size_t n = wcslen(s) + 1, size; + wchar_t *ret; + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n, sizeof(wchar_t), &size, SIZE_MAX)) { + errno = ENOMEM; + enprintf(status, "wcsdup:"); + } + ret = aligned_alloc(_Alignof(wchar_t), size); + if (!ret) + enprintf(status, "wcsdup:"); + wmemcpy(ret, s, n); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + return 0; +} + +#endif -- cgit v1.2.3-70-g09d2