winhttp: Use return value of sprintf() instead of calling strlen() and simplify code.

Signed-off-by: Carlo Bramini <carlo_bramini@users.sourceforge.net>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Carlo Bramini 2016-11-12 10:47:00 +01:00 committed by Alexandre Julliard
parent f9b878101e
commit 613e23976e
1 changed files with 2 additions and 8 deletions

View File

@ -400,8 +400,7 @@ static BOOL calc_length( URL_COMPONENTS *uc, DWORD flags, LPDWORD len )
{ {
WCHAR port[sizeof("65535")]; WCHAR port[sizeof("65535")];
sprintfW( port, formatW, uc->nPort ); *len += sprintfW( port, formatW, uc->nPort );
*len += strlenW( port );
*len += 1; /* ":" */ *len += 1; /* ":" */
} }
if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */ if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */
@ -497,15 +496,10 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
if (!uses_default_port( scheme, uc->nPort )) if (!uses_default_port( scheme, uc->nPort ))
{ {
WCHAR port[sizeof("65535")];
sprintfW( port, formatW, uc->nPort );
*url = ':'; *url = ':';
url++; url++;
len = strlenW( port ); url += sprintfW( url, formatW, uc->nPort );
memcpy( url, port, len * sizeof(WCHAR) );
url += len;
} }
/* add slash between hostname and path if necessary */ /* add slash between hostname and path if necessary */