Hi,

I have allocated memory for a Uint8Array in JS using the following code:


var nDataBytes = array.length * array.BYTES_PER_ELEMENT;
var dataPtr = Module._malloc(nDataBytes);

// Copy data to Emscripten heap (directly accessed from Module.HEAPU8)
var dataHeap = new Uint8Array(Module.HEAPU8.buffer, dataPtr, nDataBytes);
dataHeap.set(new Uint8Array(array.buffer));

return dataHeap.byteOffset;

I then return the pointer to the memory thru dataHeap.byteOffset to my C++ 
code. Do I have to free the memory in dataPtr and dataHeap.byteOffset in my 
C++ code explicitly using the free and delete calls respectively?

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to