From 4ae60c6f006a1f6da054b46bbc371b5256a12db9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 2 Mar 2009 03:19:18 +0100 Subject: [PATCH] urlmon: Move strndupW implementation to header file. --- dlls/urlmon/http.c | 20 ++++---------------- dlls/urlmon/urlmon_main.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index edaa3409b75..87d2036167a 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -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; diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index bc2fea8c0cb..36862d1570f 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -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;