Commit 8418962f authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

msscript: Use CRT allocation functions.

parent a3c3283c
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(msscript); WINE_DEFAULT_DEBUG_CHANNEL(msscript);
...@@ -280,7 +279,7 @@ static void clear_named_items(ScriptHost *host) ...@@ -280,7 +279,7 @@ static void clear_named_items(ScriptHost *host)
list_remove(&item->entry); list_remove(&item->entry);
SysFreeString(item->name); SysFreeString(item->name);
IDispatch_Release(item->disp); IDispatch_Release(item->disp);
heap_free(item); free(item);
} }
} }
...@@ -388,14 +387,14 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object, ...@@ -388,14 +387,14 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object,
if (host_get_named_item(host, name)) if (host_get_named_item(host, name))
return E_INVALIDARG; return E_INVALIDARG;
item = heap_alloc(sizeof(*item)); item = malloc(sizeof(*item));
if (!item) if (!item)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
item->name = SysAllocString(name); item->name = SysAllocString(name);
if (!item->name) if (!item->name)
{ {
heap_free(item); free(item);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
IDispatch_AddRef(item->disp = object); IDispatch_AddRef(item->disp = object);
...@@ -407,7 +406,7 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object, ...@@ -407,7 +406,7 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object,
list_remove(&item->entry); list_remove(&item->entry);
IDispatch_Release(item->disp); IDispatch_Release(item->disp);
SysFreeString(item->name); SysFreeString(item->name);
heap_free(item); free(item);
return hr; return hr;
} }
...@@ -498,7 +497,7 @@ static HRESULT run_procedure(ScriptModule *module, BSTR procedure_name, SAFEARRA ...@@ -498,7 +497,7 @@ static HRESULT run_procedure(ScriptModule *module, BSTR procedure_name, SAFEARRA
dp.cArgs = args->rgsabound[0].cElements; dp.cArgs = args->rgsabound[0].cElements;
dp.rgdispidNamedArgs = NULL; dp.rgdispidNamedArgs = NULL;
dp.cNamedArgs = 0; dp.cNamedArgs = 0;
dp.rgvarg = heap_alloc(dp.cArgs * sizeof(*dp.rgvarg)); dp.rgvarg = malloc(dp.cArgs * sizeof(*dp.rgvarg));
if (!dp.rgvarg) return E_OUTOFMEMORY; if (!dp.rgvarg) return E_OUTOFMEMORY;
hr = SafeArrayLock(args); hr = SafeArrayLock(args);
...@@ -522,7 +521,7 @@ static HRESULT run_procedure(ScriptModule *module, BSTR procedure_name, SAFEARRA ...@@ -522,7 +521,7 @@ static HRESULT run_procedure(ScriptModule *module, BSTR procedure_name, SAFEARRA
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
} }
} }
heap_free(dp.rgvarg); free(dp.rgvarg);
return hr; return hr;
} }
...@@ -668,7 +667,7 @@ static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface) ...@@ -668,7 +667,7 @@ static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
if(!ref) { if(!ref) {
clear_named_items(This); clear_named_items(This);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -908,7 +907,7 @@ static ULONG WINAPI ScriptProcedure_Release(IScriptProcedure *iface) ...@@ -908,7 +907,7 @@ static ULONG WINAPI ScriptProcedure_Release(IScriptProcedure *iface)
{ {
list_remove(&This->entry); list_remove(&This->entry);
SysFreeString(This->name); SysFreeString(This->name);
heap_free(This); free(This);
} }
return ref; return ref;
} }
...@@ -1054,7 +1053,7 @@ static HRESULT get_script_procedure(ScriptProcedureCollection *procedures, IType ...@@ -1054,7 +1053,7 @@ static HRESULT get_script_procedure(ScriptProcedureCollection *procedures, IType
} }
} }
if (!(proc = heap_alloc(sizeof(*proc)))) if (!(proc = malloc(sizeof(*proc))))
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
SysFreeString(str); SysFreeString(str);
...@@ -1115,7 +1114,7 @@ static ULONG WINAPI procedure_enum_Release(IEnumVARIANT *iface) ...@@ -1115,7 +1114,7 @@ static ULONG WINAPI procedure_enum_Release(IEnumVARIANT *iface)
if (!ref) if (!ref)
{ {
IScriptProcedureCollection_Release(&This->procedures->IScriptProcedureCollection_iface); IScriptProcedureCollection_Release(&This->procedures->IScriptProcedureCollection_iface);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1200,7 +1199,7 @@ static HRESULT WINAPI procedure_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **p ...@@ -1200,7 +1199,7 @@ static HRESULT WINAPI procedure_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **p
if (!ppEnum) return E_POINTER; if (!ppEnum) return E_POINTER;
if (!(clone = heap_alloc(sizeof(*clone)))) if (!(clone = malloc(sizeof(*clone))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*clone = *This; *clone = *This;
...@@ -1267,7 +1266,7 @@ static ULONG WINAPI ScriptProcedureCollection_Release(IScriptProcedureCollection ...@@ -1267,7 +1266,7 @@ static ULONG WINAPI ScriptProcedureCollection_Release(IScriptProcedureCollection
This->module->procedures = NULL; This->module->procedures = NULL;
IScriptModule_Release(&This->module->IScriptModule_iface); IScriptModule_Release(&This->module->IScriptModule_iface);
heap_free(This); free(This);
} }
return ref; return ref;
} }
...@@ -1359,7 +1358,7 @@ static HRESULT WINAPI ScriptProcedureCollection_get__NewEnum(IScriptProcedureCol ...@@ -1359,7 +1358,7 @@ static HRESULT WINAPI ScriptProcedureCollection_get__NewEnum(IScriptProcedureCol
count = attr->cFuncs; count = attr->cFuncs;
ITypeInfo_ReleaseTypeAttr(ti, attr); ITypeInfo_ReleaseTypeAttr(ti, attr);
if (!(proc_enum = heap_alloc(sizeof(*proc_enum)))) if (!(proc_enum = malloc(sizeof(*proc_enum))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
proc_enum->IEnumVARIANT_iface.lpVtbl = &procedure_enum_vtbl; proc_enum->IEnumVARIANT_iface.lpVtbl = &procedure_enum_vtbl;
...@@ -1572,7 +1571,7 @@ static ULONG WINAPI ScriptModule_Release(IScriptModule *iface) ...@@ -1572,7 +1571,7 @@ static ULONG WINAPI ScriptModule_Release(IScriptModule *iface)
detach_module(This); detach_module(This);
SysFreeString(This->name); SysFreeString(This->name);
uncache_module_objects(This); uncache_module_objects(This);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1687,7 +1686,7 @@ static HRESULT WINAPI ScriptModule_get_Procedures(IScriptModule *iface, IScriptP ...@@ -1687,7 +1686,7 @@ static HRESULT WINAPI ScriptModule_get_Procedures(IScriptModule *iface, IScriptP
ScriptProcedureCollection *procs; ScriptProcedureCollection *procs;
UINT i; UINT i;
if (!(procs = heap_alloc(sizeof(*procs)))) if (!(procs = malloc(sizeof(*procs))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
procs->IScriptProcedureCollection_iface.lpVtbl = &ScriptProcedureCollectionVtbl; procs->IScriptProcedureCollection_iface.lpVtbl = &ScriptProcedureCollectionVtbl;
...@@ -1819,7 +1818,7 @@ static ULONG WINAPI module_enum_Release(IEnumVARIANT *iface) ...@@ -1819,7 +1818,7 @@ static ULONG WINAPI module_enum_Release(IEnumVARIANT *iface)
{ {
IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface);
IScriptControl_Release(&This->control->IScriptControl_iface); IScriptControl_Release(&This->control->IScriptControl_iface);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1886,7 +1885,7 @@ static HRESULT WINAPI module_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEn ...@@ -1886,7 +1885,7 @@ static HRESULT WINAPI module_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEn
if (!ppEnum) return E_POINTER; if (!ppEnum) return E_POINTER;
if (This->host != This->control->host) return E_FAIL; if (This->host != This->control->host) return E_FAIL;
if (!(clone = heap_alloc(sizeof(*clone)))) if (!(clone = malloc(sizeof(*clone))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*clone = *This; *clone = *This;
...@@ -1912,13 +1911,13 @@ static ScriptModule *create_module(ScriptHost *host, BSTR name) ...@@ -1912,13 +1911,13 @@ static ScriptModule *create_module(ScriptHost *host, BSTR name)
{ {
ScriptModule *module; ScriptModule *module;
if (!(module = heap_alloc_zero(sizeof(*module)))) return NULL; if (!(module = calloc(1, sizeof(*module)))) return NULL;
module->IScriptModule_iface.lpVtbl = &ScriptModuleVtbl; module->IScriptModule_iface.lpVtbl = &ScriptModuleVtbl;
module->ref = 1; module->ref = 1;
if (name && !(module->name = SysAllocString(name))) if (name && !(module->name = SysAllocString(name)))
{ {
heap_free(module); free(module);
return NULL; return NULL;
} }
module->host = host; module->host = host;
...@@ -1935,7 +1934,7 @@ static void release_modules(ScriptControl *control, BOOL force_detach) ...@@ -1935,7 +1934,7 @@ static void release_modules(ScriptControl *control, BOOL force_detach)
IScriptModule_Release(&control->modules[i]->IScriptModule_iface); IScriptModule_Release(&control->modules[i]->IScriptModule_iface);
} }
heap_free(control->modules); free(control->modules);
} }
static ScriptModule *find_module(ScriptControl *control, BSTR name) static ScriptModule *find_module(ScriptControl *control, BSTR name)
...@@ -2056,7 +2055,7 @@ static HRESULT WINAPI ScriptModuleCollection_get__NewEnum(IScriptModuleCollectio ...@@ -2056,7 +2055,7 @@ static HRESULT WINAPI ScriptModuleCollection_get__NewEnum(IScriptModuleCollectio
if (!ppenumContexts) return E_POINTER; if (!ppenumContexts) return E_POINTER;
if (!This->host) return E_FAIL; if (!This->host) return E_FAIL;
if (!(module_enum = heap_alloc(sizeof(*module_enum)))) if (!(module_enum = malloc(sizeof(*module_enum))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
module_enum->IEnumVARIANT_iface.lpVtbl = &module_enum_vtbl; module_enum->IEnumVARIANT_iface.lpVtbl = &module_enum_vtbl;
...@@ -2136,7 +2135,7 @@ static HRESULT WINAPI ScriptModuleCollection_Add(IScriptModuleCollection *iface, ...@@ -2136,7 +2135,7 @@ static HRESULT WINAPI ScriptModuleCollection_Add(IScriptModuleCollection *iface,
/* See if we need to grow the array */ /* See if we need to grow the array */
if (is_power_of_2(host->module_count)) if (is_power_of_2(host->module_count))
{ {
modules = heap_realloc(This->modules, host->module_count * 2 * sizeof(*This->modules)); modules = realloc(This->modules, host->module_count * 2 * sizeof(*This->modules));
if (!modules) return E_OUTOFMEMORY; if (!modules) return E_OUTOFMEMORY;
This->modules = modules; This->modules = modules;
} }
...@@ -2264,7 +2263,7 @@ static ULONG WINAPI ScriptError_Release(IScriptError *iface) ...@@ -2264,7 +2263,7 @@ static ULONG WINAPI ScriptError_Release(IScriptError *iface)
if (!ref) if (!ref)
{ {
IScriptError_Clear(&This->IScriptError_iface); IScriptError_Clear(&This->IScriptError_iface);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -2498,7 +2497,7 @@ static HRESULT init_script_host(ScriptControl *control, const CLSID *clsid, Scri ...@@ -2498,7 +2497,7 @@ static HRESULT init_script_host(ScriptControl *control, const CLSID *clsid, Scri
*ret = NULL; *ret = NULL;
host = heap_alloc(sizeof(*host)); host = malloc(sizeof(*host));
if (!host) if (!host)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2631,7 +2630,7 @@ static ULONG WINAPI ScriptControl_Release(IScriptControl *iface) ...@@ -2631,7 +2630,7 @@ static ULONG WINAPI ScriptControl_Release(IScriptControl *iface)
IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface);
} }
IScriptError_Release(&This->error->IScriptError_iface); IScriptError_Release(&This->error->IScriptError_iface);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -2742,11 +2741,11 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan ...@@ -2742,11 +2741,11 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan
return hres; return hres;
/* Alloc global module */ /* Alloc global module */
This->modules = heap_alloc_zero(sizeof(*This->modules)); This->modules = calloc(1, sizeof(*This->modules));
if (This->modules) { if (This->modules) {
This->modules[0] = create_module(This->host, NULL); This->modules[0] = create_module(This->host, NULL);
if (!This->modules[0]) { if (!This->modules[0]) {
heap_free(This->modules); free(This->modules);
This->modules = NULL; This->modules = NULL;
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
} }
...@@ -3959,14 +3958,14 @@ static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknow ...@@ -3959,14 +3958,14 @@ static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknow
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv); TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
script_control = heap_alloc_zero(sizeof(*script_control)); script_control = calloc(1, sizeof(*script_control));
if(!script_control) if(!script_control)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
script_control->error = heap_alloc_zero(sizeof(*script_control->error)); script_control->error = calloc(1, sizeof(*script_control->error));
if(!script_control->error) if(!script_control->error)
{ {
heap_free(script_control); free(script_control);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
......
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