Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
We need to append them at the end for next patches to pass the tests. It will also be needed when implementing the SCRIPTITEM_ISPERSISTENT flag.
dlls/jscript/engine.c | 2 +- dlls/jscript/jscript.c | 26 +++++++++----------------- dlls/jscript/jscript.h | 4 ++-- 3 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 4e28b63..7da8f70 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -591,7 +591,7 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t DISPID id; HRESULT hres;
- for(item = ctx->named_items; item; item = item->next) { + LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) { if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { hres = disp_get_id(ctx, item->disp, identifier, identifier, 0, &id); if(SUCCEEDED(hres)) { diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index 5e9b153..b878aa5 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -113,7 +113,7 @@ named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsig named_item_t *item; HRESULT hr;
- for(item = ctx->named_items; item; item = item->next) { + LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) { if((item->flags & flags) == flags && !wcscmp(item->name, item_name)) { if(!item->disp && (flags || !(item->flags & SCRIPTITEM_CODEONLY))) { IUnknown *unk; @@ -414,20 +414,13 @@ static void decrease_state(JScript *This, SCRIPTSTATE state) This->ctx->host_global = NULL; }
- if(This->ctx->named_items) { - named_item_t *iter, *iter2; + while(!list_empty(&This->ctx->named_items)) { + named_item_t *iter = LIST_ENTRY(list_head(&This->ctx->named_items), named_item_t, entry);
- iter = This->ctx->named_items; - while(iter) { - iter2 = iter->next; - - if(iter->disp) - IDispatch_Release(iter->disp); - release_named_item(iter); - iter = iter2; - } - - This->ctx->named_items = NULL; + list_remove(&iter->entry); + if(iter->disp) + IDispatch_Release(iter->disp); + release_named_item(iter); }
if(This->ctx->secmgr) { @@ -681,6 +674,7 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface, ctx->version = This->version; ctx->html_mode = This->html_mode; ctx->acc = jsval_undefined(); + list_init(&ctx->named_items); heap_pool_init(&ctx->tmp_heap);
hres = create_jscaller(ctx); @@ -851,9 +845,7 @@ static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface, return E_OUTOFMEMORY; }
- item->next = This->ctx->named_items; - This->ctx->named_items = item; - + list_add_tail(&This->ctx->named_items, &item->entry); return S_OK; }
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index efd5a54..7f34b55 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -210,7 +210,7 @@ typedef struct named_item_t { DWORD flags; LPWSTR name;
- struct named_item_t *next; + struct list entry; } named_item_t;
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN; @@ -409,7 +409,7 @@ struct _script_ctx_t { IActiveScript *active_script;
struct _call_frame_t *call_ctx; - named_item_t *named_items; + struct list named_items; IActiveScriptSite *site; IInternetHostSecurityManager *secmgr; DWORD safeopt;