From 2e4fb99a869ecd44650db6f0f6e91d0bf2be6de0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Sep 2015 21:42:25 +0800 Subject: [PATCH] src: add node::FreeEnvironment public API Since debugger::Agent's interface is not exported, third party embedders will have linking errors if they call Environment's destructor directly. PR-URL: https://github.com/nodejs/node/pull/3098 Reviewed-By: Ben Noordhuis --- src/node.cc | 7 +++++++ src/node.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/node.cc b/src/node.cc index 2068488b9ea7b7..12219b026d63b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3226,6 +3226,13 @@ void LoadEnvironment(Environment* env) { f->Call(global, 1, &arg); } + +void FreeEnvironment(Environment* env) { + CHECK_NE(env, nullptr); + env->Dispose(); +} + + static void PrintHelp(); static bool ParseDebugOpt(const char* arg) { diff --git a/src/node.h b/src/node.h index ef1f629d20aa0e..f70b5f8e784382 100644 --- a/src/node.h +++ b/src/node.h @@ -196,6 +196,7 @@ NODE_EXTERN Environment* CreateEnvironment(v8::Isolate* isolate, int exec_argc, const char* const* exec_argv); NODE_EXTERN void LoadEnvironment(Environment* env); +NODE_EXTERN void FreeEnvironment(Environment* env); // NOTE: Calling this is the same as calling // CreateEnvironment() + LoadEnvironment() from above.