Commit d282a642 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Added new heap_strndupAtoW helper and use it in HttpAddRequestHeadersA.

parent 41f69916
......@@ -1376,21 +1376,17 @@ BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest,
BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
{
DWORD len;
LPWSTR hdr;
WCHAR *headers = NULL;
BOOL r;
TRACE("%p, %s, %i, %i\n", hHttpRequest, debugstr_an(lpszHeader, dwHeaderLength), dwHeaderLength, dwModifier);
len = MultiByteToWideChar( CP_ACP, 0, lpszHeader, dwHeaderLength, NULL, 0 );
hdr = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, lpszHeader, dwHeaderLength, hdr, len );
if( dwHeaderLength != ~0U )
dwHeaderLength = len;
if(lpszHeader)
headers = heap_strndupAtoW(lpszHeader, dwHeaderLength, &dwHeaderLength);
r = HttpAddRequestHeadersW( hHttpRequest, hdr, dwHeaderLength, dwModifier );
r = HttpAddRequestHeadersW(hHttpRequest, headers, dwHeaderLength, dwModifier);
heap_free( hdr );
heap_free(headers);
return r;
}
......
......@@ -166,6 +166,25 @@ static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len)
return ret;
}
static inline WCHAR *heap_strndupAtoW(const char *str, int len_a, DWORD *len_w)
{
WCHAR *ret = NULL;
if(str) {
size_t len;
if(len_a < 0) len_a = strlen(str);
len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0);
ret = heap_alloc((len+1)*sizeof(WCHAR));
if(ret) {
MultiByteToWideChar(CP_ACP, 0, str, len_a, ret, len);
ret[len] = 0;
*len_w = len;
}
}
return ret;
}
static inline WCHAR *heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment