Commit 1df98a99 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

jsproxy: Use CRT allocation functions.

parent 9f3a275d
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "dispex.h" #include "dispex.h"
#include "activscp.h" #include "activscp.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(jsproxy); WINE_DEFAULT_DEBUG_CHANNEL(jsproxy);
...@@ -50,7 +49,7 @@ static inline WCHAR *strdupAW( const char *src, int len ) ...@@ -50,7 +49,7 @@ static inline WCHAR *strdupAW( const char *src, int len )
if (src) if (src)
{ {
int dst_len = MultiByteToWideChar( CP_ACP, 0, src, len, NULL, 0 ); int dst_len = MultiByteToWideChar( CP_ACP, 0, src, len, NULL, 0 );
if ((dst = heap_alloc( (dst_len + 1) * sizeof(WCHAR) ))) if ((dst = malloc( (dst_len + 1) * sizeof(WCHAR) )))
{ {
len = MultiByteToWideChar( CP_ACP, 0, src, len, dst, dst_len ); len = MultiByteToWideChar( CP_ACP, 0, src, len, dst, dst_len );
dst[dst_len] = 0; dst[dst_len] = 0;
...@@ -65,7 +64,7 @@ static inline char *strdupWA( const WCHAR *src ) ...@@ -65,7 +64,7 @@ static inline char *strdupWA( const WCHAR *src )
if (src) if (src)
{ {
int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
if ((dst = heap_alloc( len ))) WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL ); if ((dst = malloc( len ))) WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
} }
return dst; return dst;
} }
...@@ -85,7 +84,7 @@ BOOL WINAPI InternetDeInitializeAutoProxyDll( LPSTR mime, DWORD reserved ) ...@@ -85,7 +84,7 @@ BOOL WINAPI InternetDeInitializeAutoProxyDll( LPSTR mime, DWORD reserved )
EnterCriticalSection( &cs_jsproxy ); EnterCriticalSection( &cs_jsproxy );
heap_free( global_script->text ); free( global_script->text );
global_script->text = NULL; global_script->text = NULL;
LeaveCriticalSection( &cs_jsproxy ); LeaveCriticalSection( &cs_jsproxy );
...@@ -104,17 +103,17 @@ static WCHAR *load_script( const char *filename ) ...@@ -104,17 +103,17 @@ static WCHAR *load_script( const char *filename )
if (handle == INVALID_HANDLE_VALUE) return NULL; if (handle == INVALID_HANDLE_VALUE) return NULL;
size = GetFileSize( handle, NULL ); size = GetFileSize( handle, NULL );
if (!(buffer = heap_alloc( size ))) goto done; if (!(buffer = malloc( size ))) goto done;
if (!ReadFile( handle, buffer, size, &bytes_read, NULL ) || bytes_read != size) goto done; if (!ReadFile( handle, buffer, size, &bytes_read, NULL ) || bytes_read != size) goto done;
len = MultiByteToWideChar( CP_ACP, 0, buffer, size, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, buffer, size, NULL, 0 );
if (!(script = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done; if (!(script = malloc( (len + 1) * sizeof(WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, buffer, size, script, len ); MultiByteToWideChar( CP_ACP, 0, buffer, size, script, len );
script[len] = 0; script[len] = 0;
done: done:
CloseHandle( handle ); CloseHandle( handle );
heap_free( buffer ); free( buffer );
return script; return script;
} }
...@@ -141,13 +140,13 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile ...@@ -141,13 +140,13 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile
LeaveCriticalSection( &cs_jsproxy ); LeaveCriticalSection( &cs_jsproxy );
return FALSE; return FALSE;
} }
heap_free( global_script->text ); free( global_script->text );
if ((global_script->text = strdupAW( buffer->lpszScriptBuffer, if ((global_script->text = strdupAW( buffer->lpszScriptBuffer,
buffer->dwScriptBufferSize ))) ret = TRUE; buffer->dwScriptBufferSize ))) ret = TRUE;
} }
else else
{ {
heap_free( global_script->text ); free( global_script->text );
if ((global_script->text = load_script( tmpfile ))) ret = TRUE; if ((global_script->text = load_script( tmpfile ))) ret = TRUE;
} }
...@@ -263,10 +262,10 @@ static char *get_computer_name( COMPUTER_NAME_FORMAT format ) ...@@ -263,10 +262,10 @@ static char *get_computer_name( COMPUTER_NAME_FORMAT format )
GetComputerNameExA( format, NULL, &size ); GetComputerNameExA( format, NULL, &size );
if (GetLastError() != ERROR_MORE_DATA) return NULL; if (GetLastError() != ERROR_MORE_DATA) return NULL;
if (!(ret = heap_alloc( size ))) return NULL; if (!(ret = malloc( size ))) return NULL;
if (!GetComputerNameExA( format, ret, &size )) if (!GetComputerNameExA( format, ret, &size ))
{ {
heap_free( ret ); free( ret );
return NULL; return NULL;
} }
return ret; return ret;
...@@ -295,7 +294,7 @@ static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result ) ...@@ -295,7 +294,7 @@ static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result )
if (!hostnameA) return E_OUTOFMEMORY; if (!hostnameA) return E_OUTOFMEMORY;
res = getaddrinfo( hostnameA, NULL, NULL, &ai ); res = getaddrinfo( hostnameA, NULL, NULL, &ai );
heap_free( hostnameA ); free( hostnameA );
if (res) return S_FALSE; if (res) return S_FALSE;
elem = ai; elem = ai;
...@@ -589,8 +588,8 @@ BOOL WINAPI InternetGetProxyInfo( LPCSTR url, DWORD len_url, LPCSTR hostname, DW ...@@ -589,8 +588,8 @@ BOOL WINAPI InternetGetProxyInfo( LPCSTR url, DWORD len_url, LPCSTR hostname, DW
ret = run_script( global_script->text, urlW, hostnameW, proxy, len_proxy ); ret = run_script( global_script->text, urlW, hostnameW, proxy, len_proxy );
done: done:
heap_free( hostnameW ); free( hostnameW );
heap_free( urlW ); free( urlW );
LeaveCriticalSection( &cs_jsproxy ); LeaveCriticalSection( &cs_jsproxy );
return ret; return ret;
} }
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