1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[mujs] Free nodelist in getElementsByTagName

This commit is contained in:
Witold Filipczyk 2024-08-07 18:23:47 +02:00
parent 157f90d1cc
commit f89a87882a
3 changed files with 16 additions and 8 deletions

View File

@ -90,8 +90,8 @@ mujs_init(struct module *xxx)
map_forms = attr_create_new_map();
map_rev_forms = attr_create_new_map();
map_inputs = attr_create_new_map();
map_nodelist = attr_create_new_map();
map_rev_nodelist = attr_create_new_map();
//map_nodelist = attr_create_new_map();
//map_rev_nodelist = attr_create_new_map();
//js_module_init_ok = spidermonkey_runtime_addref();
}
@ -113,8 +113,8 @@ mujs_done(struct module *xxx)
attr_delete_map(map_forms);
attr_delete_map(map_rev_forms);
attr_delete_map(map_inputs);
attr_delete_map(map_nodelist);
attr_delete_map(map_rev_nodelist);
//attr_delete_map(map_nodelist);
//attr_delete_map(map_rev_nodelist);
// if (js_module_init_ok)
// spidermonkey_runtime_release();
@ -214,6 +214,8 @@ mujs_put_interpreter(struct ecmascript_interpreter *interpreter)
assert(interpreter);
js_State *J = (js_State *)interpreter->backend_data;
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before js_gc: %s:%d\n", __FUNCTION__, __LINE__);
js_gc(J, 0);
fprintf(stderr, "Before js_freestate: %s:%d\n", __FUNCTION__, __LINE__);
#endif
js_freestate(J);

View File

@ -1349,6 +1349,7 @@ mjs_document_getElementsByTagName(js_State *J)
return;
}
mjs_push_nodelist(J, nodes);
dom_nodelist_unref(nodes);
}
static void

View File

@ -22,8 +22,8 @@
#include "ecmascript/mujs/nodelist.h"
#include "ecmascript/mujs/window.h"
void *map_nodelist;
void *map_rev_nodelist;
//void *map_nodelist;
//void *map_rev_nodelist;
static void
mjs_push_nodeList_item2(js_State *J, int idx)
@ -112,7 +112,11 @@ mjs_nodeList_toString(js_State *J)
static void
mjs_nodeList_finalizer(js_State *J, void *node)
{
attr_erase_from_map(map_nodelist, node);
//attr_erase_from_map(map_nodelist, node);
if (node) {
dom_nodelist_unref((dom_nodelist *)node);
}
}
#if 0
@ -147,6 +151,7 @@ mjs_push_nodelist(js_State *J, void *node)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
dom_nodelist_ref((dom_nodelist *)node);
js_newarray(J);
{
js_newuserdata(J, "nodelist", node, mjs_nodeList_finalizer);
@ -155,5 +160,5 @@ mjs_push_nodelist(js_State *J, void *node)
addmethod(J, "toString", mjs_nodeList_toString, 0);
mjs_nodeList_set_items(J, node);
}
attr_save_in_map(map_nodelist, node, node);
//attr_save_in_map(map_nodelist, node, node);
}