lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




2017-07-19 16:24 GMT+02:00 Jakub Jirutka <jakub@jirutka.cz>:
Hi,

I’m happy to announce the first release of brieflz [1] – Lua/C binding for BriefLZ [2], small and fast open source implementation of a Lempel-Ziv style compression algorithm by Joergen Ibsen.

BriefLZ is really very small C library, just 123 LoC compression code / 115 LoC safe decompression (or 63 LoC unsafe), and offers decent compression ratio. Of course it can’t compete in compression ratio with zlib or other “heavy” compression libraries, but it’s a good choice if you need good enough compression with minimal footprint. I found that it has much better compression ration on Lua sources than more known liblzf [3].

Just for very rough idea: 817 kiB Lua source (merged multiple sources, with a lot of comments) compressed to 243 kiB with BriefLZ, 337 kiB with liblzf, 207 kiB with gzip -9.

brieflz is available on LuaRocks [4] or as a tarball in the repository [1]. Documentation in ldoc is available on [5].


Hello Jakub,

A best practice is to use `lua_getallocf` instead of the C `malloc`/`free`.
By this way, your extension uses the same allocator than the Lua interpreter.
See the reference manual:
https://www.lua.org/manual/5.3/manual.html#lua_getallocf
https://www.lua.org/manual/5.3/manual.html#lua_Alloc
See an example:
https://github.com/fperrad/lua-csnappy/blob/master/lsnappy.c#L18-L35

François

 
Jakub

[1]: https://github.com/jirutka/brieflz.lua
[2]: https://github.com/jibsen/brieflz
[3]: https://github.com/nemequ/liblzf
[4]: https://luarocks.org/modules/jirutka/brieflz
[5]: https://jirutka.github.io/brieflz.lua/ldoc/