GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: cleanup DestroyParam when Environment exits · nodejs/node@aaf94fd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • async_wrap.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/async_wrap.cc‎

Copy file name to clipboardExpand all lines: src/async_wrap.cc
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ class DestroyParam {
348348
Global<Object> propBag;
349349
};
350350

351+
static void DestroyParamCleanupHook(void* ptr) {
352+
delete static_cast<DestroyParam*>(ptr);
353+
}
354+
351355
void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) {
352356
HandleScope scope(info.GetIsolate());
353357

@@ -356,6 +360,8 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) {
356360
p->propBag);
357361
Local<Value> val;
358362

363+
p->env->RemoveCleanupHook(DestroyParamCleanupHook, p.get());
364+
359365
if (!prop_bag->Get(p->env->context(), p->env->destroyed_string())
360366
.ToLocal(&val)) {
361367
return;
@@ -380,6 +386,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
380386
p->target.Reset(isolate, args[0].As<Object>());
381387
p->propBag.Reset(isolate, args[2].As<Object>());
382388
p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter);
389+
p->env->AddCleanupHook(DestroyParamCleanupHook, p);
383390
}
384391

385392

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.