From c76ed643484fc2e94e0533bcc2aec3e041372047 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 23 Jul 2013 16:56:22 -0700 Subject: [PATCH] smalloc: add external to alloc with callbacks Forgot to actually assign cb_info to the External in smalloc::Alloc() that accepts a callback to be run in the weak callback. --- src/smalloc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/smalloc.cc b/src/smalloc.cc index a48fd7c88a1..35220ac09b5 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -206,7 +206,7 @@ void AllocDispose(Handle obj) { HandleScope scope(node_isolate); if (using_alloc_cb && obj->Has(smalloc_sym)) { - Local ext = obj->Get(smalloc_sym).As(); + Local ext = obj->GetHiddenValue(smalloc_sym).As(); CallbackInfo* cb_info = static_cast(ext->Value()); Local obj = PersistentToLocal(cb_info->p_obj); TargetFreeCallback(node_isolate, obj, cb_info); @@ -252,6 +252,7 @@ void Alloc(Handle obj, cb_info->cb = fn; cb_info->hint = hint; cb_info->p_obj.Reset(node_isolate, obj); + obj->SetHiddenValue(smalloc_sym, External::New(cb_info)); node_isolate->AdjustAmountOfExternalAllocatedMemory(length + sizeof(*cb_info));