Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/engine.h | 2 +- dlls/jscript/jscript.c | 26 ++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index a3b598e..1d76cf8 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -185,7 +185,7 @@ typedef struct _bytecode_t { unsigned str_pool_size; unsigned str_cnt;
- struct _bytecode_t *next; + struct list entry; } bytecode_t;
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,BOOL,BOOL,bytecode_t**) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index 2a7c028..68b62b4 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -60,8 +60,7 @@ typedef struct {
IActiveScriptSite *site;
- bytecode_t *queue_head; - bytecode_t *queue_tail; + struct list queued_code; } JScript;
void script_release(script_ctx_t *ctx) @@ -117,27 +116,20 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code)
static void clear_script_queue(JScript *This) { - bytecode_t *iter, *iter2; + bytecode_t *iter, *iter_next;
- if(!This->queue_head) - return; - - iter = This->queue_head; - while(iter) { - iter2 = iter->next; - iter->next = NULL; + LIST_FOR_EACH_ENTRY_SAFE(iter, iter_next, &This->queued_code, bytecode_t, entry) + { + list_remove(&iter->entry); release_bytecode(iter); - iter = iter2; } - - This->queue_head = This->queue_tail = NULL; }
static void exec_queued_code(JScript *This) { bytecode_t *iter;
- for(iter = This->queue_head; iter; iter = iter->next) + LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) exec_global_code(This, iter);
clear_script_queue(This); @@ -793,10 +785,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, * script is executed immediately, even if it's not in started state yet. */ if(!pvarResult && !is_started(This->ctx)) { - if(This->queue_tail) - This->queue_tail = This->queue_tail->next = code; - else - This->queue_head = This->queue_tail = code; + list_add_tail(&This->queued_code, &code->entry); return S_OK; }
@@ -1089,6 +1078,7 @@ HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv) ret->ref = 1; ret->safeopt = INTERFACE_USES_DISPEX; ret->is_encode = is_encode; + list_init(&ret->queued_code);
hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv); IActiveScript_Release(&ret->IActiveScript_iface);