lua-users home
lua-l archive

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


Hi François,

Thanks you for your advice, I didn’t know about lua_getallocf / lua_Alloc! I’ve fixed it and released 0.1.1.

Jakub

On 23. Jul 2017, at 8:12, François Perrad <francois.perrad@gadz.org> wrote:

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