Commit 82198731 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

wshom: Use CRT allocation functions.

parent d1c09903
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "dispex.h" #include "dispex.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(wshom); WINE_DEFAULT_DEBUG_CHANNEL(wshom);
...@@ -49,7 +48,7 @@ typedef struct ...@@ -49,7 +48,7 @@ typedef struct
LONG ref; LONG ref;
IShellLinkW *link; IShellLinkW *link;
BSTR path_link; WCHAR *path_link;
} WshShortcut; } WshShortcut;
typedef struct typedef struct
...@@ -130,7 +129,7 @@ static ULONG WINAPI WshExec_Release(IWshExec *iface) ...@@ -130,7 +129,7 @@ static ULONG WINAPI WshExec_Release(IWshExec *iface)
if (!ref) { if (!ref) {
CloseHandle(This->info.hThread); CloseHandle(This->info.hThread);
CloseHandle(This->info.hProcess); CloseHandle(This->info.hProcess);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -321,24 +320,25 @@ static const IWshExecVtbl WshExecVtbl = { ...@@ -321,24 +320,25 @@ static const IWshExecVtbl WshExecVtbl = {
static HRESULT WshExec_create(BSTR command, IWshExec **ret) static HRESULT WshExec_create(BSTR command, IWshExec **ret)
{ {
STARTUPINFOW si = {0}; STARTUPINFOW si = {0};
WshExecImpl *This; WshExecImpl *object;
*ret = NULL; *ret = NULL;
This = heap_alloc(sizeof(*This)); if (!(object = calloc(1, sizeof(*object))))
if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IWshExec_iface.lpVtbl = &WshExecVtbl; object->IWshExec_iface.lpVtbl = &WshExecVtbl;
This->ref = 1; object->ref = 1;
if (!CreateProcessW(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &This->info)) { if (!CreateProcessW(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &object->info))
heap_free(This); {
free(object);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
init_classinfo(&CLSID_WshExec, (IUnknown *)&This->IWshExec_iface, &This->classinfo); init_classinfo(&CLSID_WshExec, (IUnknown *)&object->IWshExec_iface, &object->classinfo);
*ret = &This->IWshExec_iface; *ret = &object->IWshExec_iface;
return S_OK; return S_OK;
} }
...@@ -383,7 +383,7 @@ static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface) ...@@ -383,7 +383,7 @@ static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface)
TRACE("(%p) ref = %d\n", This, ref); TRACE("(%p) ref = %d\n", This, ref);
if (!ref) if (!ref)
heap_free(This); free(This);
return ref; return ref;
} }
...@@ -519,16 +519,16 @@ static const IWshEnvironmentVtbl WshEnvironmentVtbl = { ...@@ -519,16 +519,16 @@ static const IWshEnvironmentVtbl WshEnvironmentVtbl = {
static HRESULT WshEnvironment_Create(IWshEnvironment **env) static HRESULT WshEnvironment_Create(IWshEnvironment **env)
{ {
WshEnvironment *This; WshEnvironment *object;
This = heap_alloc(sizeof(*This)); if (!(object = calloc(1, sizeof(*object))))
if (!This) return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IWshEnvironment_iface.lpVtbl = &WshEnvironmentVtbl; object->IWshEnvironment_iface.lpVtbl = &WshEnvironmentVtbl;
This->ref = 1; object->ref = 1;
init_classinfo(&IID_IWshEnvironment, (IUnknown *)&This->IWshEnvironment_iface, &This->classinfo); init_classinfo(&IID_IWshEnvironment, (IUnknown *)&object->IWshEnvironment_iface, &object->classinfo);
*env = &This->IWshEnvironment_iface; *env = &object->IWshEnvironment_iface;
return S_OK; return S_OK;
} }
...@@ -574,7 +574,7 @@ static ULONG WINAPI WshCollection_Release(IWshCollection *iface) ...@@ -574,7 +574,7 @@ static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
TRACE("(%p) ref = %d\n", This, ref); TRACE("(%p) ref = %d\n", This, ref);
if (!ref) if (!ref)
heap_free(This); free(This);
return ref; return ref;
} }
...@@ -718,16 +718,16 @@ static const IWshCollectionVtbl WshCollectionVtbl = { ...@@ -718,16 +718,16 @@ static const IWshCollectionVtbl WshCollectionVtbl = {
static HRESULT WshCollection_Create(IWshCollection **collection) static HRESULT WshCollection_Create(IWshCollection **collection)
{ {
WshCollection *This; WshCollection *object;
This = heap_alloc(sizeof(*This)); if (!(object = calloc(1, sizeof(*object))))
if (!This) return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IWshCollection_iface.lpVtbl = &WshCollectionVtbl; object->IWshCollection_iface.lpVtbl = &WshCollectionVtbl;
This->ref = 1; object->ref = 1;
init_classinfo(&IID_IWshCollection, (IUnknown *)&This->IWshCollection_iface, &This->classinfo); init_classinfo(&IID_IWshCollection, (IUnknown *)&object->IWshCollection_iface, &object->classinfo);
*collection = &This->IWshCollection_iface; *collection = &object->IWshCollection_iface;
return S_OK; return S_OK;
} }
...@@ -775,9 +775,9 @@ static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface) ...@@ -775,9 +775,9 @@ static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface)
if (!ref) if (!ref)
{ {
SysFreeString(This->path_link);
IShellLinkW_Release(This->link); IShellLinkW_Release(This->link);
heap_free(This); free(This->path_link);
free(This);
} }
return ref; return ref;
...@@ -1070,35 +1070,34 @@ static const IWshShortcutVtbl WshShortcutVtbl = { ...@@ -1070,35 +1070,34 @@ static const IWshShortcutVtbl WshShortcutVtbl = {
static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut) static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut)
{ {
WshShortcut *This; WshShortcut *object;
HRESULT hr; HRESULT hr;
*shortcut = NULL; *shortcut = NULL;
This = heap_alloc(sizeof(*This)); if (!(object = calloc(1, sizeof(*object))))
if (!This) return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IWshShortcut_iface.lpVtbl = &WshShortcutVtbl; object->IWshShortcut_iface.lpVtbl = &WshShortcutVtbl;
This->ref = 1; object->ref = 1;
hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (void **)&object->link);
&IID_IShellLinkW, (void**)&This->link);
if (FAILED(hr)) if (FAILED(hr))
{ {
heap_free(This); free(object);
return hr; return hr;
} }
This->path_link = SysAllocString(path); object->path_link = wcsdup(path);
if (!This->path_link) if (!object->path_link)
{ {
IShellLinkW_Release(This->link); IShellLinkW_Release(object->link);
heap_free(This); free(object);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
init_classinfo(&IID_IWshShortcut, (IUnknown *)&This->IWshShortcut_iface, &This->classinfo); init_classinfo(&IID_IWshShortcut, (IUnknown *)&object->IWshShortcut_iface, &object->classinfo);
*shortcut = (IDispatch*)&This->IWshShortcut_iface; *shortcut = (IDispatch *)&object->IWshShortcut_iface;
return S_OK; return S_OK;
} }
...@@ -1220,7 +1219,7 @@ static WCHAR *split_command( BSTR cmd, WCHAR **params ) ...@@ -1220,7 +1219,7 @@ static WCHAR *split_command( BSTR cmd, WCHAR **params )
WCHAR *ret, *ptr; WCHAR *ret, *ptr;
BOOL in_quotes = FALSE; BOOL in_quotes = FALSE;
if (!(ret = heap_alloc((lstrlenW(cmd) + 1) * sizeof(WCHAR)))) return NULL; if (!(ret = malloc((lstrlenW(cmd) + 1) * sizeof(WCHAR)))) return NULL;
lstrcpyW( ret, cmd ); lstrcpyW( ret, cmd );
*params = NULL; *params = NULL;
...@@ -1283,7 +1282,7 @@ static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, ...@@ -1283,7 +1282,7 @@ static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style,
info.nShow = V_I4(&s); info.nShow = V_I4(&s);
ret = ShellExecuteExW(&info); ret = ShellExecuteExW(&info);
heap_free( file ); free(file);
if (!ret) if (!ret)
{ {
TRACE("ShellExecute failed, %d\n", GetLastError()); TRACE("ShellExecute failed, %d\n", GetLastError());
...@@ -1454,7 +1453,7 @@ static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value) ...@@ -1454,7 +1453,7 @@ static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value)
unsigned int len = *value - *subkey - 1; unsigned int len = *value - *subkey - 1;
WCHAR *ret; WCHAR *ret;
ret = heap_alloc((len + 1)*sizeof(WCHAR)); ret = malloc((len + 1)*sizeof(WCHAR));
if (!ret) if (!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1494,7 +1493,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v ...@@ -1494,7 +1493,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v
if (ret == ERROR_SUCCESS) { if (ret == ERROR_SUCCESS) {
void *data; void *data;
data = heap_alloc(datalen); data = malloc(datalen);
if (!data) { if (!data) {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
goto fail; goto fail;
...@@ -1502,7 +1501,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v ...@@ -1502,7 +1501,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v
ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, data, &datalen); ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, data, &datalen);
if (ret) { if (ret) {
heap_free(data); free(data);
hr = HRESULT_FROM_WIN32(ret); hr = HRESULT_FROM_WIN32(ret);
goto fail; goto fail;
} }
...@@ -1592,7 +1591,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v ...@@ -1592,7 +1591,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v
hr = E_FAIL; hr = E_FAIL;
}; };
heap_free(data); free(data);
if (FAILED(hr)) if (FAILED(hr))
VariantInit(value); VariantInit(value);
} }
...@@ -1601,7 +1600,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v ...@@ -1601,7 +1600,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v
fail: fail:
if (val) if (val)
heap_free(subkey); free(subkey);
return hr; return hr;
} }
...@@ -1684,7 +1683,7 @@ static HRESULT WINAPI WshShell3_RegWrite(IWshShell3 *iface, BSTR name, VARIANT * ...@@ -1684,7 +1683,7 @@ static HRESULT WINAPI WshShell3_RegWrite(IWshShell3 *iface, BSTR name, VARIANT *
fail: fail:
VariantClear(&v); VariantClear(&v);
if (val) if (val)
heap_free(subkey); free(subkey);
return hr; return hr;
} }
......
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