summaryrefslogtreecommitdiffstats
path: root/include/slang.h
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-07-24 11:44:13 -0700
committerGitHub <noreply@github.com>2024-07-24 11:44:13 -0700
commit657213f13d49f0d2caaa8b64c1245ec8c75fc4d7 (patch)
tree02f2a6dca56ea384c88095e75b24691d5253d204 /include/slang.h
parenta1607f802ae0a42ffafd2c37d76779873264d371 (diff)
Cleanup global memory allocations on shutdown. (#4731)
Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
Diffstat (limited to 'include/slang.h')
-rw-r--r--include/slang.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/slang.h b/include/slang.h
index 6fd6da7b2..849532fc8 100644
--- a/include/slang.h
+++ b/include/slang.h
@@ -5351,6 +5351,14 @@ Returns nullptr if there isn't an embedded stdlib.
*/
SLANG_API ISlangBlob* slang_getEmbeddedStdLib();
+
+/* Cleanup all global allocations used by Slang, to prevent memory leak detectors from
+ reporting them as leaks. This function should only be called after all Slang objects
+ have been released. No other Slang functions such as `createGlobalSession`
+ should be called after this function.
+ */
+SLANG_EXTERN_C SLANG_API void slang_shutdown();
+
namespace slang
{
inline SlangResult createGlobalSession(
@@ -5358,6 +5366,7 @@ namespace slang
{
return slang_createGlobalSession(SLANG_API_VERSION, outGlobalSession);
}
+ inline void shutdown() { slang_shutdown(); }
}
/** @see slang::ICompileRequest::getProgram