From 7527c8d3d78a09620efab3634cd2aa9f67a29a49 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 11 Jan 2022 11:33:02 +0300 Subject: [PATCH] hidapi, libusb: provide a wcsdup implementation if it is not available. similar to mac and android versions.. --- src/hidapi/libusb/hid.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c index d4fd9da69..296af5b4e 100644 --- a/src/hidapi/libusb/hid.c +++ b/src/hidapi/libusb/hid.c @@ -31,9 +31,24 @@ #include "SDL_thread.h" #include "SDL_mutex.h" -#if defined(HAVE__WCSDUP) && !defined(HAVE_WCSDUP) +#ifndef HAVE_WCSDUP +#ifdef HAVE__WCSDUP #define wcsdup _wcsdup +#else +#define wcsdup _dupwcs +static wchar_t *_dupwcs(const wchar_t *src) +{ + wchar_t *dst = NULL; + if (src) { + size_t len = SDL_wcslen(src) + 1; + len *= sizeof(wchar_t); + dst = (wchar_t *) malloc(len); + if (dst) memcpy(dst, src, len); + } + return dst; +} #endif +#endif /* HAVE_WCSDUP */ #include #include /* setlocale */