mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
7ab9a3f36d
At some point while setting up the utils subdirectory, I apparently only got half way through renaming miscucs.c to dup_mb_to_wc.c: I created the new copy of the file, but I didn't delete the old one, I didn't mention it in utils/CMakeLists.txt, and I didn't change the comment at the top. Now done all three, so we now have just one copy of this utility module.
30 lines
728 B
C
30 lines
728 B
C
/*
|
|
* dup_mb_to_wc: memory-allocating wrapper on mb_to_wc.
|
|
*
|
|
* Also dup_mb_to_wc_c: same but you already know the length of the
|
|
* string.
|
|
*/
|
|
|
|
#include "putty.h"
|
|
#include "misc.h"
|
|
|
|
wchar_t *dup_mb_to_wc_c(int codepage, int flags, const char *string, int len)
|
|
{
|
|
int mult;
|
|
for (mult = 1 ;; mult++) {
|
|
wchar_t *ret = snewn(mult*len + 2, wchar_t);
|
|
int outlen;
|
|
outlen = mb_to_wc(codepage, flags, string, len, ret, mult*len + 1);
|
|
if (outlen < mult*len+1) {
|
|
ret[outlen] = L'\0';
|
|
return ret;
|
|
}
|
|
sfree(ret);
|
|
}
|
|
}
|
|
|
|
wchar_t *dup_mb_to_wc(int codepage, int flags, const char *string)
|
|
{
|
|
return dup_mb_to_wc_c(codepage, flags, string, strlen(string));
|
|
}
|