Closed 821869798 closed 4 years ago
嗯,unsafe
但是我要把 const char data = (const char )lua_touserdata(L, 2); 中的lua_touserdata换成lua_tostring才行, 不然传入的C#字节数组类型不是userdata导致报错: "userdata expected, got string"
你传错类型了,如果是string,那么必须是完整消息。如果要指定长度,你得搞成IntPtr再传
还有一个办法:使用slice接口来传递,slice接口接受string并且接受范围参数
@821869798 请教下这个问题你最后咋个处理的?
@821869798 请教下这个问题你最后咋个处理的?
@songtm 以下是我的方法
local pb = require("pb") local pb_slice = require("pb.slice") local msg = pb.decode(protoName,pb_slice.new(msgData.RawData,1,msgData.RawDataLen)) --msgData.RawData 字节数组 --msgData.RawDataLen 反序列化指定的长度
@821869798 谢谢,我最终是把xlua的 push byte[] 改成直接调用xlua_pushlstring
pb.decode 如何指定C#字节数组长度,为了避免GC,我在C#端做了缓存字节数组,有什么方法指定长度?用unsafe吗?