-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
First, thanks for the cool library. But I ran into a head scratcher. Using the node-ffi example in the README.md, I found that any specific array type constructor used in the FFI declaration has to be the exact constructor used to create the array instances when invoking the FFI'd method -- or a segmentation fault 11 occurs. Said another way, two declarations of a "float array" constructor are not compatible.
If we define
const ArrayType = require('ref-array');
const FloatArray = ArrayType('float');
use that in our FFI declaration
const libadd = ffi.Library(__dirname + '/libadd', {
add: ['float', [ FloatArray, 'int' ] ]
});
then declare the float array constructor a second time
const FloatArray2 = ArrayType('float');
and pass an array created with it to libadd.add, a seg fault occurs.
libadd.add(new FloatArray2([1.1, 2.2, 3.3], 3));
A complete simple example can be found in the "bug" branch of my fork.
Metadata
Metadata
Assignees
Labels
No labels