Skip to content

Commit

Permalink
remove _attach call in writePointer
Browse files Browse the repository at this point in the history
remove _attach call in writePointer as
it is no longer needed since a stronger
version is done in the native code
when true is passed as the fourth parameter
  • Loading branch information
mhdawson committed Mar 11, 2021
1 parent 4cf8eed commit 63cd269
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ref.js
Expand Up @@ -746,8 +746,12 @@ exports.writeObject = function writeObject (buf, offset, obj) {

exports.writePointer = function writePointer (buf, offset, ptr) {
debug('writing pointer to buffer', buf, offset, ptr);
// Passing true as a fourth parameter does an a stronger
// version of attach which ensures ptr is only collected after
// the finalizer for buf has run. See
// https://github.com/node-ffi-napi/ref-napi/issues/54
// for why this is necessary
exports._writePointer(buf, offset, ptr, true);
exports._attach(buf, ptr);
};

/**
Expand Down

0 comments on commit 63cd269

Please sign in to comment.