Use WideByteToMultiChar not strlenW.

Use HeapAlloc, not malloc.
This commit is contained in:
Mike McCormack 2003-08-15 03:47:30 +00:00 committed by Alexandre Julliard
parent ea6584d42c
commit 43629c9b5b
1 changed files with 26 additions and 22 deletions

View File

@ -302,34 +302,38 @@ HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
if (lpszVerb) if (lpszVerb)
{ {
len = lstrlenW(lpszVerb)+1; len = WideCharToMultiByte(CP_ACP, 0, lpszVerb, -1, NULL, 0, NULL, NULL);
if (!(szVerb = (CHAR *) HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)))) szVerb = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR) );
if ( !szVerb )
goto end; goto end;
WideCharToMultiByte(CP_ACP, -1, lpszVerb, -1, szVerb, len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszVerb, -1, szVerb, len, NULL, NULL);
} }
if (lpszObjectName) if (lpszObjectName)
{ {
len = lstrlenW(lpszObjectName)+1; len = WideCharToMultiByte(CP_ACP, 0, lpszObjectName, -1, NULL, 0, NULL, NULL);
if (!(szObjectName = (CHAR *) HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)))) szObjectName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR) );
if ( !szObjectName )
goto end; goto end;
WideCharToMultiByte(CP_ACP, -1, lpszObjectName, -1, szObjectName, len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszObjectName, -1, szObjectName, len, NULL, NULL);
} }
if (lpszVersion) if (lpszVersion)
{ {
len = lstrlenW(lpszVersion)+1; len = WideCharToMultiByte(CP_ACP, 0, lpszVersion, -1, NULL, 0, NULL, NULL);
if (!(szVersion = (CHAR *) HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)))) szVersion = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
if ( !szVersion )
goto end; goto end;
WideCharToMultiByte(CP_ACP, -1, lpszVersion, -1, szVersion, len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszVersion, -1, szVersion, len, NULL, NULL);
} }
if (lpszReferrer) if (lpszReferrer)
{ {
len = lstrlenW(lpszReferrer)+1; len = WideCharToMultiByte(CP_ACP, 0, lpszReferrer, -1, NULL, 0, NULL, NULL);
if (!(szReferrer = (CHAR *) HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)))) szReferrer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
if ( !szReferrer )
goto end; goto end;
WideCharToMultiByte(CP_ACP, -1, lpszReferrer, -1, szReferrer, len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszReferrer, -1, szReferrer, len, NULL, NULL);
} }
acceptTypesCount = 0; acceptTypesCount = 0;
@ -340,11 +344,12 @@ HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
acceptTypesCount = 0; acceptTypesCount = 0;
while (lpszAcceptTypes[acceptTypesCount]) while (lpszAcceptTypes[acceptTypesCount])
{ {
len = lstrlenW(lpszAcceptTypes[acceptTypesCount])+1; len = WideCharToMultiByte(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
if (!(szAcceptTypes[acceptTypesCount] = (CHAR *) HeapAlloc(GetProcessHeap(), -1, NULL, 0, NULL, NULL);
0, len * sizeof(CHAR)))) szAcceptTypes[acceptTypesCount] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
if (!szAcceptTypes[acceptTypesCount] )
goto end; goto end;
WideCharToMultiByte(CP_ACP, -1, lpszAcceptTypes[acceptTypesCount], WideCharToMultiByte(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
-1, szAcceptTypes[acceptTypesCount], len, NULL, NULL); -1, szAcceptTypes[acceptTypesCount], len, NULL, NULL);
acceptTypesCount++; acceptTypesCount++;
} }
@ -1009,14 +1014,13 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
DWORD nLen=dwHeaderLength; DWORD nLen=dwHeaderLength;
if(lpszHeaders!=NULL) if(lpszHeaders!=NULL)
{ {
if(nLen==-1) nLen=WideCharToMultiByte(CP_ACP,0,lpszHeaders,dwHeaderLength,NULL,0,NULL,NULL);
nLen=strlenW(lpszHeaders); szHeaders=HeapAlloc(GetProcessHeap(),0,nLen);
szHeaders=(char*)malloc(nLen+1); WideCharToMultiByte(CP_ACP,0,lpszHeaders,dwHeaderLength,szHeaders,nLen,NULL,NULL);
WideCharToMultiByte(CP_ACP,0,lpszHeaders,nLen,szHeaders,nLen,NULL,NULL);
} }
result=HttpSendRequestA(hHttpRequest, szHeaders, dwHeaderLength, lpOptional, dwOptionalLength); result=HttpSendRequestA(hHttpRequest, szHeaders, nLen, lpOptional, dwOptionalLength);
if(szHeaders!=NULL) if(szHeaders!=NULL)
free(szHeaders); HeapFree(GetProcessHeap(),0,szHeaders);
return result; return result;
} }