MCPcopy Index your code
hub / github.com/nodejs/node / writePointerArg

Function writePointerArg

lib/internal/ffi-shared-buffer.js:161–179  ·  view source on GitHub ↗
(view, offset, arg, index)

Source from the content-addressed store, hash-verified

159// Returns true on fast-path success, false when the caller must fall back
160// to the slow path (strings, Buffers, ArrayBuffers, ArrayBufferViews).
161function writePointerArg(view, offset, arg, index) {
162 if (typeof arg === 'bigint') {
163 // Bound by `uintptrMax` (not `U64_MAX`) to mirror the slow path: on
164 // 32-bit platforms a BigInt that doesn't fit in `uintptr_t` would be
165 // silently truncated by `ReadFFIArgFromBuffer`'s
166 // `memcpy(..., type->size, ...)`.
167 if (arg < 0n || arg > uintptrMax) {
168 throwFFIArgError(
169 `Argument ${index} must be a non-negative pointer bigint`);
170 }
171 sU64(view, offset, arg, true);
172 return true;
173 }
174 if (arg === null || arg === undefined) {
175 sU64(view, offset, 0n, true);
176 return true;
177 }
178 return false;
179}
180
181// The `pointer` descriptor mirrors the raw function's so user code that
182// reassigns `.pointer` keeps working through the wrapper.

Callers 1

wrapWithSharedBufferFunction · 0.85

Calls 1

throwFFIArgErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…