Skip to content

Commit c76ed64

Browse files
committed
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.
1 parent 8ce02cf commit c76ed64

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/smalloc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void AllocDispose(Handle<Object> obj) {
206206
HandleScope scope(node_isolate);
207207

208208
if (using_alloc_cb && obj->Has(smalloc_sym)) {
209-
Local<External> ext = obj->Get(smalloc_sym).As<External>();
209+
Local<External> ext = obj->GetHiddenValue(smalloc_sym).As<External>();
210210
CallbackInfo* cb_info = static_cast<CallbackInfo*>(ext->Value());
211211
Local<Object> obj = PersistentToLocal(cb_info->p_obj);
212212
TargetFreeCallback(node_isolate, obj, cb_info);
@@ -252,6 +252,7 @@ void Alloc(Handle<Object> obj,
252252
cb_info->cb = fn;
253253
cb_info->hint = hint;
254254
cb_info->p_obj.Reset(node_isolate, obj);
255+
obj->SetHiddenValue(smalloc_sym, External::New(cb_info));
255256

256257
node_isolate->AdjustAmountOfExternalAllocatedMemory(length +
257258
sizeof(*cb_info));

0 commit comments

Comments
 (0)