diff options
Diffstat (limited to 'lib/quickjs/quickjs.c')
-rw-r--r-- | lib/quickjs/quickjs.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index af7ea852..427b36df 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -306,6 +306,7 @@ struct JSRuntime { uint32_t operator_count; #endif void *user_opaque; + JSRuntimeCleanUpFunc *user_cleanup; }; struct JSClass { @@ -1703,6 +1704,11 @@ void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque) rt->user_opaque = opaque; } +void JS_SetRuntimeCleanUpFunc(JSRuntime *rt, JSRuntimeCleanUpFunc cleanup_func) +{ + rt->user_cleanup = cleanup_func; +} + /* default memory allocation functions with memory limitation */ static size_t js_def_malloc_usable_size(const void *ptr) { @@ -1960,6 +1966,8 @@ void JS_FreeRuntime(JSRuntime *rt) JS_RunGC(rt); + rt->user_cleanup(rt); + #ifdef DUMP_LEAKS /* leaking objects */ { |