[gjs/wip/ptomato/mozjs31: 22/23] WIP - destroy runtime



commit 81af81001ea4d58fc82283ffb62b7121491f903b
Author: Philip Chimento <philip endlessm com>
Date:   Tue Nov 8 16:35:37 2016 -0800

    WIP - destroy runtime

 gjs/runtime.cpp              |    8 +++++++-
 gjs/runtime.h                |    2 ++
 installed-tests/gjs-unit.cpp |    2 ++
 3 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gjs/runtime.cpp b/gjs/runtime.cpp
index 6fd9467..05e51db 100644
--- a/gjs/runtime.cpp
+++ b/gjs/runtime.cpp
@@ -151,8 +151,8 @@ destroy_runtime(gpointer data)
     JSRuntime *runtime = (JSRuntime *) data;
     RuntimeData *rtdata = (RuntimeData *) JS_GetRuntimePrivate(runtime);
 
-    g_free(rtdata);
     JS_DestroyRuntime(runtime);
+    g_free(rtdata);
 }
 
 static GPrivate thread_runtime = G_PRIVATE_INIT(destroy_runtime);
@@ -246,3 +246,9 @@ gjs_runtime_for_current_thread(void)
 
     return runtime;
 }
+
+void
+gjs_destroy_runtime_for_current_thread(void)
+{
+    g_private_replace(&thread_runtime, NULL);
+}
diff --git a/gjs/runtime.h b/gjs/runtime.h
index 0900e28..914fdee 100644
--- a/gjs/runtime.h
+++ b/gjs/runtime.h
@@ -28,6 +28,8 @@
 
 JSRuntime * gjs_runtime_for_current_thread (void);
 
+void gjs_destroy_runtime_for_current_thread(void);
+
 bool        gjs_runtime_is_sweeping        (JSRuntime *runtime);
 
 #endif /* __GJS_RUNTIME_H__ */
diff --git a/installed-tests/gjs-unit.cpp b/installed-tests/gjs-unit.cpp
index 7f85cff..8251662 100644
--- a/installed-tests/gjs-unit.cpp
+++ b/installed-tests/gjs-unit.cpp
@@ -34,6 +34,7 @@
 
 #include "gjs/coverage.h"
 #include "gjs/mem.h"
+#include "gjs/runtime.h"
 
 typedef struct {
     const char *coverage_prefix;
@@ -105,6 +106,7 @@ teardown(GjsTestJSFixture *fix,
 
     gjs_memory_report("before destroying context", false);
     g_object_unref(fix->context);
+    gjs_destroy_runtime_for_current_thread();
     gjs_memory_report("after destroying context", true);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]