Comments (4)
是 i386 or x86_64 平台?能否提供錯誤訊息?
在 lz4.lua:122 這段 dest_buf + hdr_len
我實測是沒有問題的
可以看一下 Travis CI 的頁面,LuaJIT 2.0.4 與 2.1 都正常
關於 dest_buf
這 cdata
的算數計算,我是參考 FFI Semantics - Arithmetic on cdata objects
from ljlz4.
是i386
我的应用场景没有使用dll或so,而是将lz4直接以static lib形式嵌入宿主程序
然后导出C函数给Lua使用
这是该函数代码
static int compress(lua_State *L)
{
char* dest = (char*)lua_topointer(L, 1);
int destOff = lua_tonumber(L, 2);
int destLen = lua_tonumber(L, 3);
const char* src = lua_tostring(L, 4);
int srcLen = lua_tonumber(L, 5);
int cpLen = LZ4_compressBound(srcLen);
if (cpLen > destLen)
{
lua_pushnumber(L, -1);
return 1;
}
cpLen = LZ4_compress_limitedOutput(src, dest + destOff, srcLen, destLen);
lua_pushnumber(L, cpLen);
return 1;
}
我简单测试了下,每次dest_buf + hdr_len
似乎都会产生的新的cdata,导致压缩数据存放到其它地址,而dest_buf
原地址上除了lz4_hdr_t
数据,后面的全为0。
我不清楚lz4.so是否做过相应处理,现在我传入destOff
是为了能在C中进行正确的指针偏移。
对FFI底层实现不大清楚,求教~
from ljlz4.
看來你是混用 Lua C API 與 LuaJIT FFI 了,LuaJIT 作者 Mike 有提示過不能這樣用
供你參考 Re: Accessing ctype of FFI cdata from the Lua C API
from ljlz4.
非常感谢,看来是混用的问题
from ljlz4.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ljlz4.