memset没有DLL,所以如何ctype它 [英] memset has no DLL so how ctype it

查看:219
本文介绍了memset没有DLL,所以如何ctype它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jsctypes中使用 memset 。没有它的DLL。被困在这两天。如果你只是想要 memset 一个数组为零字节,然后我有好消息,每个人:js-ctypes将初始化新的数组为零。



<否则,最简单的方法就是创建一个类型化数组,初始化它,然后创建一个指向它的指针。 / b>

显然你也可以直接在ctypes数组上设置数组元素(假设数组类型已知大小)...

  //请注意,size是要设置的数组元素的数量,
//不是字节数。
函数memset(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])


How to use memset in jsctypes. There no DLL for it. Been stuck on this for two days. I searched/scoured js ctype codes couldn't find an example to rip.

解决方案

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.
function memset(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])"

这篇关于memset没有DLL,所以如何ctype它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆