Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
Simplifies the 5th patch.
dlls/vbscript/vbdisp.c | 28 ++++++++++++++++++++-------- dlls/vbscript/vbscript.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index 36eba21..666da11 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -1243,19 +1243,12 @@ static ULONG WINAPI ScriptDisp_Release(IDispatchEx *iface) { ScriptDisp *This = ScriptDisp_from_IDispatchEx(iface); LONG ref = InterlockedDecrement(&This->ref); - unsigned i;
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) { assert(!This->ctx); - - for (i = 0; i < This->global_vars_cnt; i++) - release_dynamic_var(This->global_vars[i]); - - heap_pool_free(&This->heap); - heap_free(This->global_vars); - heap_free(This->global_funcs); + reset_script_disp(This); heap_free(This); }
@@ -1500,6 +1493,25 @@ HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret) return S_OK; }
+void reset_script_disp(ScriptDisp *disp) +{ + unsigned i; + + for (i = 0; i < disp->global_vars_cnt; i++) + release_dynamic_var(disp->global_vars[i]); + + heap_free(disp->global_vars); + heap_free(disp->global_funcs); + heap_pool_free(&disp->heap); + heap_pool_init(&disp->heap); + + disp->global_vars_cnt = disp->global_vars_size = 0; + disp->global_funcs_cnt = disp->global_funcs_size = 0; + disp->global_vars = NULL; + disp->global_funcs = NULL; + disp->classes = NULL; +} + void collect_objects(script_ctx_t *ctx) { vbdisp_t *iter, *iter2; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index f37b0ce..10c8f00 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -164,6 +164,7 @@ HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,WORD,DISPPARAMS*) DECLSPEC_ HRESULT get_disp_value(script_ctx_t*,IDispatch*,VARIANT*) DECLSPEC_HIDDEN; void collect_objects(script_ctx_t*) DECLSPEC_HIDDEN; HRESULT create_script_disp(script_ctx_t*,ScriptDisp**) DECLSPEC_HIDDEN; +void reset_script_disp(ScriptDisp*) DECLSPEC_HIDDEN;
HRESULT to_int(VARIANT*,int*) DECLSPEC_HIDDEN;