Nikolay Sivov nsivov@codeweavers.com wrote:
+DWORD WINAPI SHAnsiToAnsi(const char *src, char *dest, int dest_len) +{
- DWORD ret = 0;
- TRACE("(%s, %p, %d)\n", debugstr_a(src), dest, dest_len);
- if (!src || !dest || dest_len <= 0)
return 0;
- while (dest_len > 1 && *src)
- {
dest_len--;
ret++;
*dest++ = *src++;
- }
- if (dest_len)
- {
*dest = 0;
ret++;
- }
- return ret;
+}
What is the reason to duplicate lstrcpynA?
+DWORD WINAPI SHUnicodeToAnsi(const WCHAR *src, char *dest, int dest_len) +{
- char *buff;
- int len;
- TRACE("(%s, %p, %d)\n", debugstr_w(src), dest, dest_len);
- len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);
- buff = heap_alloc(len);
- if (!buff)
return 0;
- WideCharToMultiByte(CP_ACP, 0, src, -1, buff, len, NULL, NULL);
- len = SHAnsiToAnsi(buff, dest, dest_len);
- heap_free(buff);
- return len;
+}
It should be possible to do without an intermediate memory allocation.
+DWORD WINAPI SHUnicodeToUnicode(const WCHAR *src, WCHAR *dest, int dest_len) +{
- DWORD ret = 0;
- TRACE("(%s, %p, %d)\n", debugstr_w(src), dest, dest_len);
- if (!src || !dest || dest_len <= 0)
return 0;
- while (dest_len > 1 && *src)
- {
dest_len--;
ret++;
*dest++ = *src++;
- }
- if (dest_len)
- {
*dest = 0;
ret++;
- }
- return ret;
+}
What is the reason to duplicate lstrcpynW?
+DWORD WINAPI SHAnsiToUnicode(const char *src, WCHAR *dest, int dest_len) +{
- WCHAR *buffW;
- int len;
- TRACE("(%s, %p, %d)\n", debugstr_a(src), dest, dest_len);
- len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
- buffW = heap_alloc(len * sizeof(*buffW));
- if (!buffW)
return 0;
- MultiByteToWideChar(CP_ACP, 0, src, -1, buffW, len);
- len = SHUnicodeToUnicode(buffW, dest, dest_len);
- heap_free(buffW);
- return len;
+}
It should be possible to do without an intermediate memory allocation.