-- v2: jscript: Remove unused function heap_strdupW. jscript: Use standard C functions for memory allocation in jscript.c.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/jscript/dispex.c | 62 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 42f41771ef2..699e4c87b52 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -189,7 +189,7 @@ static inline HRESULT resize_props(jsdisp_t *This) if(This->buf_size != This->prop_cnt) return S_FALSE;
- props = heap_realloc(This->props, sizeof(dispex_prop_t)*This->buf_size*2); + props = realloc(This->props, sizeof(dispex_prop_t) * This->buf_size * 2); if(!props) return E_OUTOFMEMORY; This->buf_size *= 2; @@ -220,7 +220,7 @@ static inline dispex_prop_t* alloc_prop(jsdisp_t *This, const WCHAR *name, prop_ return NULL;
prop = &This->props[This->prop_cnt]; - prop->name = heap_strdupW(name); + prop->name = wcsdup(name); if(!prop->name) return NULL; prop->type = type; @@ -420,7 +420,7 @@ static HRESULT convert_params(script_ctx_t *ctx, const DISPPARAMS *dp, jsval_t * cnt = dp->cArgs - dp->cNamedArgs;
if(cnt > 6) { - argv = heap_alloc(cnt * sizeof(*argv)); + argv = malloc(cnt * sizeof(*argv)); if(!argv) return E_OUTOFMEMORY; }else { @@ -433,7 +433,7 @@ static HRESULT convert_params(script_ctx_t *ctx, const DISPPARAMS *dp, jsval_t * while(i--) jsval_release(argv[i]); if(argv != buf) - heap_free(argv); + free(argv); return hres; } } @@ -775,9 +775,9 @@ static ULONG WINAPI ScriptTypeInfo_Release(ITypeInfo *iface) for (i = This->num_funcs; i--;) release_bytecode(This->funcs[i].code->bytecode); IDispatchEx_Release(&This->jsdisp->IDispatchEx_iface); - heap_free(This->funcs); - heap_free(This->vars); - heap_free(This); + free(This->funcs); + free(This->vars); + free(This); } return ref; } @@ -791,7 +791,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetTypeAttr(ITypeInfo *iface, TYPEATTR **pp
if (!ppTypeAttr) return E_INVALIDARG;
- attr = heap_alloc_zero(sizeof(*attr)); + attr = calloc(1, sizeof(*attr)); if (!attr) return E_OUTOFMEMORY;
attr->guid = GUID_JScriptTypeInfo; @@ -840,7 +840,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetFuncDesc(ITypeInfo *iface, UINT index, F func = &This->funcs[index];
/* Store the parameter array after the FUNCDESC structure */ - desc = heap_alloc_zero(sizeof(*desc) + sizeof(ELEMDESC) * func->code->param_cnt); + desc = calloc(1, sizeof(*desc) + sizeof(ELEMDESC) * func->code->param_cnt); if (!desc) return E_OUTOFMEMORY;
desc->memid = prop_to_id(This->jsdisp, func->prop); @@ -868,7 +868,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetVarDesc(ITypeInfo *iface, UINT index, VA if (!ppVarDesc) return E_INVALIDARG; if (index >= This->num_vars) return TYPE_E_ELEMENTNOTFOUND;
- desc = heap_alloc_zero(sizeof(*desc)); + desc = calloc(1, sizeof(*desc)); if (!desc) return E_OUTOFMEMORY;
desc->memid = prop_to_id(This->jsdisp, This->vars[index]); @@ -1213,7 +1213,7 @@ static void WINAPI ScriptTypeInfo_ReleaseTypeAttr(ITypeInfo *iface, TYPEATTR *pT
TRACE("(%p)->(%p)\n", This, pTypeAttr);
- heap_free(pTypeAttr); + free(pTypeAttr); }
static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pFuncDesc) @@ -1222,7 +1222,7 @@ static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pF
TRACE("(%p)->(%p)\n", This, pFuncDesc);
- heap_free(pFuncDesc); + free(pFuncDesc); }
static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVarDesc) @@ -1231,7 +1231,7 @@ static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVar
TRACE("(%p)->(%p)\n", This, pVarDesc);
- heap_free(pVarDesc); + free(pVarDesc); }
static const ITypeInfoVtbl ScriptTypeInfoVtbl = { @@ -1464,7 +1464,7 @@ static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC else num_vars++; }
- if (!(typeinfo = heap_alloc(sizeof(*typeinfo)))) + if (!(typeinfo = malloc(sizeof(*typeinfo)))) return E_OUTOFMEMORY;
typeinfo->ITypeInfo_iface.lpVtbl = &ScriptTypeInfoVtbl; @@ -1474,18 +1474,18 @@ static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC typeinfo->num_funcs = num_funcs; typeinfo->jsdisp = This;
- typeinfo->funcs = heap_alloc(sizeof(*typeinfo->funcs) * num_funcs); + typeinfo->funcs = malloc(sizeof(*typeinfo->funcs) * num_funcs); if (!typeinfo->funcs) { - heap_free(typeinfo); + free(typeinfo); return E_OUTOFMEMORY; }
- typeinfo->vars = heap_alloc(sizeof(*typeinfo->vars) * num_vars); + typeinfo->vars = malloc(sizeof(*typeinfo->vars) * num_vars); if (!typeinfo->vars) { - heap_free(typeinfo->funcs); - heap_free(typeinfo); + free(typeinfo->funcs); + free(typeinfo); return E_OUTOFMEMORY; }
@@ -1614,7 +1614,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc hres = jsdisp_call_value(This, get_this(pdp), wFlags, argc, argv, pvarRes ? &r : NULL);
if(argv != buf) - heap_free(argv); + free(argv); if(SUCCEEDED(hres) && pvarRes) { hres = jsval_to_variant(r, pvarRes); jsval_release(r); @@ -1830,7 +1830,7 @@ HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *b dispex->extensible = TRUE; dispex->prop_cnt = 0;
- dispex->props = heap_alloc_zero(sizeof(dispex_prop_t)*(dispex->buf_size=4)); + dispex->props = calloc(1, sizeof(dispex_prop_t)*(dispex->buf_size=4)); if(!dispex->props) return E_OUTOFMEMORY;
@@ -1862,13 +1862,13 @@ HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsd jsdisp_t *ret; HRESULT hres;
- ret = heap_alloc_zero(sizeof(jsdisp_t)); + ret = calloc(1, sizeof(jsdisp_t)); if(!ret) return E_OUTOFMEMORY;
hres = init_dispex(ret, ctx, builtin_info ? builtin_info : &dispex_info, prototype); if(FAILED(hres)) { - heap_free(ret); + free(ret); return hres; }
@@ -1896,9 +1896,9 @@ void jsdisp_free(jsdisp_t *obj) default: break; }; - heap_free(prop->name); + free(prop->name); } - heap_free(obj->props); + free(obj->props); script_release(obj->ctx); if(obj->prototype) jsdisp_release(obj->prototype); @@ -1906,7 +1906,7 @@ void jsdisp_free(jsdisp_t *obj) if(obj->builtin_info->destructor) obj->builtin_info->destructor(obj); else - heap_free(obj); + free(obj); }
#ifdef TRACE_REFCNT @@ -2128,7 +2128,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns }
if(dp.cArgs > ARRAY_SIZE(buf)) { - dp.rgvarg = heap_alloc(argc*sizeof(VARIANT)); + dp.rgvarg = malloc(argc * sizeof(VARIANT)); if(!dp.rgvarg) return E_OUTOFMEMORY; }else { @@ -2141,7 +2141,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns while(i--) VariantClear(dp.rgvarg+argc-i-1); if(dp.rgvarg != buf) - heap_free(dp.rgvarg); + free(dp.rgvarg); return hres; } } @@ -2152,7 +2152,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns for(i=0; i<argc; i++) VariantClear(dp.rgvarg+argc-i-1); if(dp.rgvarg != buf) - heap_free(dp.rgvarg); + free(dp.rgvarg);
if(SUCCEEDED(hres) && ret) hres = variant_to_jsval(ctx, &retv, ret); @@ -2223,7 +2223,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W dp.rgdispidNamedArgs = NULL; }
- if(dp.cArgs > ARRAY_SIZE(buf) && !(args = heap_alloc(dp.cArgs * sizeof(VARIANT)))) + if(dp.cArgs > ARRAY_SIZE(buf) && !(args = malloc(dp.cArgs * sizeof(VARIANT)))) return E_OUTOFMEMORY; dp.rgvarg = args;
@@ -2243,7 +2243,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W for(i = 0; i < argc; i++) VariantClear(dp.rgvarg + dp.cArgs - i - 1); if(args != buf) - heap_free(args); + free(args);
if(FAILED(hres)) return hres;
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/jscript/jscript.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index 190a2876900..a138d26db3f 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -88,7 +88,7 @@ void script_release(script_ctx_t *ctx) ctx->jscaller->ctx = NULL; IServiceProvider_Release(&ctx->jscaller->IServiceProvider_iface);
- heap_free(ctx); + free(ctx); }
static void script_globals_release(script_ctx_t *ctx) @@ -192,8 +192,8 @@ void release_named_item(named_item_t *item) { if(--item->ref) return;
- heap_free(item->name); - heap_free(item); + free(item->name); + free(item); }
static inline JScriptError *impl_from_IActiveScriptError(IActiveScriptError *iface) @@ -240,7 +240,7 @@ static ULONG WINAPI JScriptError_Release(IActiveScriptError *iface)
if(!ref) { reset_ei(&This->ei); - heap_free(This); + free(This); }
return ref; @@ -367,7 +367,7 @@ HRESULT leave_script(script_ctx_t *ctx, HRESULT result) } if(FAILED(result)) { WARN("%08lx\n", result); - if(ctx->site && (error = heap_alloc(sizeof(*error)))) { + if(ctx->site && (error = malloc(sizeof(*error)))) { HRESULT hres;
error->IActiveScriptError_iface.lpVtbl = &JScriptErrorVtbl; @@ -575,7 +575,7 @@ static ULONG WINAPI AXSite_Release(IServiceProvider *iface) if(This->sp) IServiceProvider_Release(This->sp);
- heap_free(This); + free(This); }
return ref; @@ -612,7 +612,7 @@ IUnknown *create_ax_site(script_ctx_t *ctx) TRACE("Could not get IServiceProvider iface: %08lx\n", hres); }
- ret = heap_alloc(sizeof(AXSite)); + ret = malloc(sizeof(AXSite)); if(!ret) { IServiceProvider_Release(sp); return NULL; @@ -695,7 +695,7 @@ static ULONG WINAPI JScript_Release(IActiveScript *iface) This->ctx->active_script = NULL; script_release(This->ctx); } - heap_free(This); + free(This); unlock_module(); }
@@ -722,7 +722,7 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface, return E_UNEXPECTED;
if(!This->ctx) { - script_ctx_t *ctx = heap_alloc_zero(sizeof(script_ctx_t)); + script_ctx_t *ctx = calloc(1, sizeof(script_ctx_t)); if(!ctx) return E_OUTOFMEMORY;
@@ -738,7 +738,7 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
hres = create_jscaller(ctx); if(FAILED(hres)) { - heap_free(ctx); + free(ctx); return hres; }
@@ -895,7 +895,7 @@ static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface, } }
- item = heap_alloc(sizeof(*item)); + item = malloc(sizeof(*item)); if(!item) { if(disp) IDispatch_Release(disp); @@ -906,11 +906,11 @@ static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface, item->disp = disp; item->flags = dwFlags; item->script_obj = NULL; - item->name = heap_strdupW(pstrName); + item->name = wcsdup(pstrName); if(!item->name) { if(disp) IDispatch_Release(disp); - heap_free(item); + free(item); return E_OUTOFMEMORY; }
@@ -1414,7 +1414,7 @@ HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv) JScript *ret; HRESULT hres;
- ret = heap_alloc_zero(sizeof(*ret)); + ret = calloc(1, sizeof(*ret)); if(!ret) return E_OUTOFMEMORY;
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/jscript/jscript.h | 16 ---------------- 1 file changed, 16 deletions(-)
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 757abf8aa6d..94a2ff76fd7 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -70,22 +70,6 @@ void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN; void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN; heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
-static inline LPWSTR heap_strdupW(LPCWSTR str) -{ - LPWSTR ret = NULL; - - if(str) { - DWORD size; - - size = (lstrlenW(str)+1)*sizeof(WCHAR); - ret = heap_alloc(size); - if(ret) - memcpy(ret, str, size); - } - - return ret; -} - typedef struct jsdisp_t jsdisp_t;
extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126385
Your paranoid android.
=== debian11 (32 bit report) ===
d3d9: stateblock: Timeout visual: Timeout
d3dcompiler_43: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_46: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_47: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3drm: d3drm: Timeout vector: Timeout
d3dx10_34: d3dx10: Timeout
d3dx10_35: d3dx10: Timeout
d3dx10_36: d3dx10: Timeout
Report validation errors: d3dx10: Timeout
=== debian11 (build log) ===
WineRunWineTest.pl:error: The task timed out
On Fri Nov 18 16:21:30 2022 +0000, Alex Henrie wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/1426/diffs?diff_id=19532&start_sha=cbda79d200fb6e4c92e284430eb785606c2e4cf6#2fb64d232c5a4aa3454425817f3802ae2f678fec_86_86)
My bad. Thank you for catching that.
Do you plan to convert the entire module soon (i.e. next week)? I have a lot of jscript patches and it would be a pain to only replace some of them, much easier to just search/replace everything at once when rebasing. (otherwise I could take a jab at doing it after this MR is in)
This merge request was approved by Jacek Caban.