“内存集"没有DLL,所以怎么ctype [英] "memset" has no DLL so how ctype it

查看:73
本文介绍了“内存集"没有DLL,所以怎么ctype的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jsctypes中使用memset.没有它的DLL.我搜索/搜索了js ctype代码,但找不到要翻录的示例.

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.

推荐答案

如果您只想将数组memset设置为零字节,那么我有一个好消息,大家":js-ctypes会将新数组初始化为零.

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.

显然,这些天,您也可以直接在ctypes数组上设置数组元素(前提是数组类型的大小已知)...

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])"

这篇关于“内存集"没有DLL,所以怎么ctype的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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