mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[spidermonkey] option change hook to not read option too often
This commit is contained in:
parent
0ac1329d65
commit
7d05730ac7
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "config/options.h"
|
|
||||||
#include "js/spidermonkey-shared.h"
|
#include "js/spidermonkey-shared.h"
|
||||||
#include <js/Initialization.h>
|
#include <js/Initialization.h>
|
||||||
|
|
||||||
@ -28,6 +27,9 @@ static int spidermonkey_runtime_refcount;
|
|||||||
*
|
*
|
||||||
* @return 1 if successful or 0 on error. If this succeeds, the
|
* @return 1 if successful or 0 on error. If this succeeds, the
|
||||||
* caller must eventually call spidermonkey_runtime_release(). */
|
* caller must eventually call spidermonkey_runtime_release(). */
|
||||||
|
|
||||||
|
long spidermonkey_memory_limit;
|
||||||
|
|
||||||
int
|
int
|
||||||
spidermonkey_runtime_addref(void)
|
spidermonkey_runtime_addref(void)
|
||||||
{
|
{
|
||||||
@ -37,7 +39,7 @@ spidermonkey_runtime_addref(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_ctx = JS_NewContext(get_opt_long("ecmascript.spidermonkey.memory_limit", NULL));
|
main_ctx = JS_NewContext(spidermonkey_memory_limit);
|
||||||
|
|
||||||
if (!main_ctx) {
|
if (!main_ctx) {
|
||||||
JS_ShutDown();
|
JS_ShutDown();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
extern JSRuntime *spidermonkey_runtime;
|
extern JSRuntime *spidermonkey_runtime;
|
||||||
extern JSContext *main_ctx;
|
extern JSContext *main_ctx;
|
||||||
|
extern long spidermonkey_memory_limit;
|
||||||
int spidermonkey_runtime_addref(void);
|
int spidermonkey_runtime_addref(void);
|
||||||
void spidermonkey_runtime_release(void);
|
void spidermonkey_runtime_release(void);
|
||||||
|
|
||||||
|
@ -134,9 +134,24 @@ reported:
|
|||||||
JS_ClearPendingException(ctx);
|
JS_ClearPendingException(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
change_hook_spidermonkey(struct session *ses, struct option *current, struct option *changed)
|
||||||
|
{
|
||||||
|
spidermonkey_memory_limit = get_opt_long("ecmascript.spidermonkey.memory_limit", ses);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spidermonkey_init(struct module *module)
|
spidermonkey_init(struct module *module)
|
||||||
{
|
{
|
||||||
|
static const struct change_hook_info spidermonkey_change_hooks[] = {
|
||||||
|
{ "ecmascript.spidermonkey.memory_limit", change_hook_spidermonkey },
|
||||||
|
{ NULL, NULL },
|
||||||
|
};
|
||||||
|
register_change_hooks(spidermonkey_change_hooks);
|
||||||
|
spidermonkey_memory_limit = get_opt_long("ecmascript.spidermonkey.memory_limit", NULL);
|
||||||
|
|
||||||
js_module_init_ok = spidermonkey_runtime_addref();
|
js_module_init_ok = spidermonkey_runtime_addref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user