From d5dc63244321fb5a1b371446919d953c58d33c40 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 27 Oct 2023 20:37:50 +0200 Subject: [PATCH] [mujs] memcount mem_realloc and mem_free for mujs Also commented code in mujs_element_init. It caused only a memory leak. --- src/ecmascript/libdom/mujs/element.c | 5 +++-- src/util/memcount.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ecmascript/libdom/mujs/element.c b/src/ecmascript/libdom/mujs/element.c index 9d469ccd..5e38f8e9 100644 --- a/src/ecmascript/libdom/mujs/element.c +++ b/src/ecmascript/libdom/mujs/element.c @@ -2612,7 +2612,7 @@ mjs_push_element(js_State *J, void *node) void *second = attr_find_in_map(map_privates, node); - if (0 && second) { + if (second) { el_private = (struct mjs_element_private *)second; if (!attr_find_in_map(map_elements, el_private)) { @@ -2705,9 +2705,10 @@ mjs_push_element(js_State *J, void *node) int mjs_element_init(js_State *J) { +#if 0 mjs_push_element(J, NULL); js_defglobal(J, "Element", JS_DONTENUM); - +#endif return 0; } diff --git a/src/util/memcount.cpp b/src/util/memcount.cpp index 7c21f017..1be022d0 100644 --- a/src/util/memcount.cpp +++ b/src/util/memcount.cpp @@ -413,7 +413,7 @@ el_mujs_alloc(void *memctx, void *ptr, int size) fprintf(stderr, "mujs free %p not found\n", ptr); return NULL; } - free(ptr); + mem_free(ptr); el_mujs_allocs.erase(el); return NULL; } @@ -428,7 +428,7 @@ el_mujs_alloc(void *memctx, void *ptr, int size) el_mujs_allocs.erase(el); } } - void *ret = realloc(ptr, (size_t)size); + void *ret = mem_realloc(ptr, (size_t)size); if (ret) { el_mujs_allocs[ret] = (uint64_t)size;