I have a c++ function that accepts 2 arrays and multiplies them together.
void multData(unsigned char *arr1, unsigned char *arr2) {
for(i=0;i<10;i++){
arr1[i] = arr1[i] * arr2[i];
}
}
When I compile it I allocate space for both arrays in the heap using malloc.
var mallocBuff = Module._malloc(arr1.length);
var mallocBuff2 = Module._malloc(arr2.length);
Then after filling the newly malloced data with values I'll call it like this:
Module.ccall('multData', null, ['number'], [mallocBuff], [mallocBuff2]);
However after some testing I realize that only the first array is receiving the malloc pointer. The second array is just a bunch of 0's.
Is there anyway to pass 2 arrays into a wasm compiled function?