jscript: Reference-count the named items.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
747c46a4bc
commit
3d23f095bf
|
@ -143,6 +143,14 @@ named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsig
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void release_named_item(named_item_t *item)
|
||||
{
|
||||
if(--item->ref) return;
|
||||
|
||||
heap_free(item->name);
|
||||
heap_free(item);
|
||||
}
|
||||
|
||||
static inline JScriptError *impl_from_IActiveScriptError(IActiveScriptError *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, JScriptError, IActiveScriptError_iface);
|
||||
|
@ -415,8 +423,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
|
|||
|
||||
if(iter->disp)
|
||||
IDispatch_Release(iter->disp);
|
||||
heap_free(iter->name);
|
||||
heap_free(iter);
|
||||
release_named_item(iter);
|
||||
iter = iter2;
|
||||
}
|
||||
|
||||
|
@ -833,6 +840,7 @@ static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface,
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
item->ref = 1;
|
||||
item->disp = disp;
|
||||
item->flags = dwFlags;
|
||||
item->name = heap_strdupW(pstrName);
|
||||
|
|
|
@ -206,6 +206,7 @@ HRESULT builtin_set_const(script_ctx_t*,jsdisp_t*,jsval_t) DECLSPEC_HIDDEN;
|
|||
|
||||
typedef struct named_item_t {
|
||||
IDispatch *disp;
|
||||
unsigned ref;
|
||||
DWORD flags;
|
||||
LPWSTR name;
|
||||
|
||||
|
@ -213,6 +214,7 @@ typedef struct named_item_t {
|
|||
} named_item_t;
|
||||
|
||||
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
|
||||
void release_named_item(named_item_t*) DECLSPEC_HIDDEN;
|
||||
|
||||
typedef struct {
|
||||
const WCHAR *name;
|
||||
|
|
Loading…
Reference in New Issue