You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a SAB using JS_NewArrayBuffer, the alloc_flag is always set to FALSE, which means we assume A SAB was previously allocated and we are just going to "dup" it.
This doesn't work when all we want to is to maneuver a chunk of memory (I have this use case with FFI) since we didn't allocate the SAB in the first place.
I reckon we might want some JS_NewSharedArrayBuffer function to provide extra flexibility. In addition JSFreeArrayBufferDataFunc doesn't apply for a SAB so we'd make it more specific.
I worked this around on txiki.js by adding a magic number to the SAB header, this way I can detect if we allocated the SAB or if it's just external memory, but it's a hack at best.
When creating a SAB using
JS_NewArrayBuffer
, thealloc_flag
is always set toFALSE
, which means we assume A SAB was previously allocated and we are just going to "dup" it.This doesn't work when all we want to is to maneuver a chunk of memory (I have this use case with FFI) since we didn't allocate the SAB in the first place.
I reckon we might want some
JS_NewSharedArrayBuffer
function to provide extra flexibility. In additionJSFreeArrayBufferDataFunc
doesn't apply for a SAB so we'd make it more specific.I worked this around on txiki.js by adding a magic number to the SAB header, this way I can detect if we allocated the SAB or if it's just external memory, but it's a hack at best.
Thoughts @chqrlie / @bnoordhuis ?
The text was updated successfully, but these errors were encountered: