From 2a8bd35bac64691506c7c66ae131ac28793be18a 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 34e49e98d4dedf..f71c2714a830d8 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3386,6 +3386,13 @@ void LoadEnvironment(Environment* env) { f->Call(Null(env->isolate()), 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 529ee75f279053..42c5ac59d7ecf2 100644 --- a/src/node.h +++ b/src/node.h @@ -200,6 +200,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.