1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

New utility function: dupwcs.

Just like dupstr, but for wchar_t strings.
This commit is contained in:
Simon Tatham
2023-05-28 11:49:12 +01:00
parent 5f43d11f83
commit 36db93748e
3 changed files with 21 additions and 0 deletions

View File

@ -25,6 +25,7 @@ add_sources_from_current_dir(utils
dupcat.c
dupprintf.c
dupstr.c
dupwcs.c
dup_mb_to_wc.c
dup_wc_to_mb.c
encode_utf8.c

19
utils/dupwcs.c Normal file
View File

@ -0,0 +1,19 @@
/*
* Allocate a duplicate of a NUL-terminated wchar_t string.
*/
#include <wchar.h>
#include "defs.h"
#include "misc.h"
wchar_t *dupwcs(const wchar_t *s)
{
wchar_t *p = NULL;
if (s) {
int len = wcslen(s);
p = snewn(len + 1, wchar_t);
wcscpy(p, s);
}
return p;
}