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

Function withAllocations

test/ffi/test-ffi-memory.js:20–36  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

18after(() => lib.close());
19
20function withAllocations(fn) {
21 const allocations = new Set();
22
23 function alloc(size) {
24 const ptr = symbols.allocate_memory(BigInt(size));
25 allocations.add(ptr);
26 return ptr;
27 }
28
29 try {
30 fn(alloc);
31 } finally {
32 for (const ptr of allocations) {
33 symbols.deallocate_memory(ptr);
34 }
35 }
36}
37
38test('ffi reads and writes integer and float values', () => {
39 withAllocations(common.mustCall((alloc) => {

Callers 1

test-ffi-memory.jsFile · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…