Skip to content Skip to sidebar Skip to footer

"memset" Has No Dll So How Ctype It

How to use memset in jsctypes. There no DLL for it. I searched/scoured js ctype codes but couldn't find an example to rip.

Solution 1:

If you just want to memset an array to zero-bytes, then I have "Good news, everyone": js-ctypes will initialize new arrays to zero.

Otherwise it would be probably easiest to just create a typed array, initialize it, and create a pointer to it.

Apparently you can also set array elements directly on a ctypes array these days (provided the array type has a known size)...

// Note that size is the number of array elements to set,// not the number of bytes.functionmemset(array, val, size) {
 for (var i = 0; i < size; ++i) {
   array[i] = val;
 }
}

var a = ctypes.uint8_t.array()(10);
memset(a, 0xde, a.length);
console.log(a.toSource());
// "ctypes.uint8_t.array(10)([222, 222, 222, 222, 222, 222, 222, 222, 222, 222])"

Post a Comment for ""memset" Has No Dll So How Ctype It"