1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

[spidermonkey] fun dynamically allocated

This commit is contained in:
Witold Filipczyk 2024-06-30 16:00:26 +02:00
parent 298588ad18
commit 55979c1551
3 changed files with 12 additions and 4 deletions

View File

@ -334,6 +334,9 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
foreach (t, interpreter->timeouts) {
kill_timer(&t->tid);
done_string(&t->code);
#ifdef CONFIG_ECMASCRIPT_SMJS
delete(t->fun);
#endif
#ifdef CONFIG_QUICKJS
if (!JS_IsNull(t->fun)) {
JS_FreeValue(t->ctx, t->fun);

View File

@ -490,8 +490,12 @@ ecmascript_timeout_handler2(void *val)
assertm(interpreter->vs->doc_view != NULL,
"setTimeout: vs with no document (e_f %d)",
interpreter->vs->ecmascript_fragile);
#ifdef CONFIG_ECMASCRIPT_SMJS
JS::RootedValue vfun((JSContext *)interpreter->backend_data, *(t->fun));
ecmascript_call_function(interpreter, vfun, NULL);
#else
ecmascript_call_function(interpreter, t->fun, NULL);
#endif
if (t->timeout_next > 0) {
install_timer(&t->tid, t->timeout_next, ecmascript_timeout_handler2, t);
} else {
@ -578,7 +582,7 @@ ecmascript_set_timeout2(void *c, JS::HandleValue f, int timeout, int timeout_nex
t->ctx = ctx;
t->timeout_next = timeout_next;
JS::RootedValue fun((JSContext *)interpreter->backend_data, f);
t->fun = fun;
t->fun = new JS::Heap<JS::Value>(fun);
add_to_list(interpreter->timeouts, t);
install_timer(&t->tid, timeout, ecmascript_timeout_handler2, t);

View File

@ -13,6 +13,7 @@
#ifdef CONFIG_ECMASCRIPT_SMJS
#include <jsapi.h>
#include <jsfriendapi.h>
#endif
#ifdef CONFIG_QUICKJS
@ -107,7 +108,7 @@ struct ecmascript_interpreter {
JSValueConst fun;
#endif
#ifdef CONFIG_ECMASCRIPT_SMJS
JS::RootedValue fun;
JS::Heap<JS::Value> *fun;
#endif
#ifdef CONFIG_MUJS
const char *fun;
@ -126,7 +127,7 @@ struct ecmascript_timeout {
#endif
#ifdef CONFIG_ECMASCRIPT_SMJS
JSContext *ctx;
JS::RootedValue fun;
JS::Heap<JS::Value> *fun;
#endif
#ifdef CONFIG_MUJS
js_State *ctx;