Module: wine Branch: master Commit: 4960f9e338c49be92c05c15d61b5aebc5e07da32 URL: https://source.winehq.org/git/wine.git/?a=commit;h=4960f9e338c49be92c05c15d6...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Aug 14 13:18:00 2019 +0200
jscript: Move function destructor implementation into vtbl.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/function.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 54ff411..3b50a5d 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -41,6 +41,7 @@ typedef struct {
struct _function_vtbl_t { HRESULT (*toString)(FunctionInstance*,jsstr_t**); + void (*destructor)(FunctionInstance*); };
typedef struct { @@ -555,13 +556,9 @@ static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval
static void Function_destructor(jsdisp_t *dispex) { - FunctionInstance *This = function_from_jsdisp(dispex); - - if(This->code) - release_bytecode(This->code); - if(This->scope_chain) - scope_release(This->scope_chain); - heap_free(This); + FunctionInstance *function = function_from_jsdisp(dispex); + function->vtbl->destructor(function); + heap_free(function); }
static const builtin_prop_t Function_props[] = { @@ -649,8 +646,13 @@ static HRESULT NativeFunction_toString(FunctionInstance *function, jsstr_t **ret return S_OK; }
+static void NativeFunction_destructor(FunctionInstance *function) +{ +} + static const function_vtbl_t NativeFunctionVtbl = { NativeFunction_toString, + NativeFunction_destructor };
HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, @@ -714,8 +716,16 @@ static HRESULT InterpretedFunction_toString(FunctionInstance *function, jsstr_t return *ret ? S_OK : E_OUTOFMEMORY; }
+static void InterpretedFunction_destructor(FunctionInstance *function) +{ + release_bytecode(function->code); + if(function->scope_chain) + scope_release(function->scope_chain); +} + static const function_vtbl_t InterpretedFunctionVtbl = { InterpretedFunction_toString, + InterpretedFunction_destructor };
HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_code_t *func_code,