urlmon: Move strndupW implementation to header file.

This commit is contained in:
Jacek Caban 2009-03-02 03:19:18 +01:00 committed by Alexandre Julliard
parent b0a9ddae67
commit 4ae60c6f00
2 changed files with 19 additions and 16 deletions

View File

@ -219,18 +219,6 @@ static void CALLBACK HTTPPROTOCOL_InternetStatusCallback(
IInternetProtocolSink_ReportProgress(This->base.protocol_sink, ulStatusCode, (LPWSTR)lpvStatusInformation);
}
static inline LPWSTR strndupW(LPCWSTR string, int len)
{
LPWSTR ret = NULL;
if (string &&
(ret = heap_alloc((len+1)*sizeof(WCHAR))) != NULL)
{
memcpy(ret, string, len*sizeof(WCHAR));
ret[len] = 0;
}
return ret;
}
/*
* Interface implementations
*/
@ -345,10 +333,10 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
hres = MK_E_SYNTAX;
goto done;
}
host = strndupW(url.lpszHostName, url.dwHostNameLength);
path = strndupW(url.lpszUrlPath, url.dwUrlPathLength);
user = strndupW(url.lpszUserName, url.dwUserNameLength);
pass = strndupW(url.lpszPassword, url.dwPasswordLength);
host = heap_strndupW(url.lpszHostName, url.dwHostNameLength);
path = heap_strndupW(url.lpszUrlPath, url.dwUrlPathLength);
user = heap_strndupW(url.lpszUserName, url.dwUserNameLength);
pass = heap_strndupW(url.lpszPassword, url.dwPasswordLength);
if (!url.nPort)
url.nPort = This->https ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;

View File

@ -133,6 +133,21 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return ret;
}
static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
{
LPWSTR ret = NULL;
if(str) {
ret = heap_alloc((len+1)*sizeof(WCHAR));
if(ret) {
memcpy(ret, str, len*sizeof(WCHAR));
ret[len] = 0;
}
}
return ret;
}
static inline LPWSTR heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;