lua-users home
lua-l archive

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


> if the new allocator is not fully compatible with the default
> one (for example because you have offset the returned pointer to
> include a UID in the chunk), Lua will crash at exit.

Ah, simply including the uid in a neighboring chunk of memory is a great idea. 
If I do that, do I need to worry about the size of LUAI_USER_ALIGNMENT_T at all?
 Its purpose is not entirely clear to me.

> The best way is to replace the initial call to the convenience
> function luaL_newstate() with a call to the core function
> lua_newstate(lua_Alloc f, void *ud), passing along your new allocator
> function.
> To write that allocation function, start by copying the reference
> implementation showed in
> http://www.lua.org/manual/5.2/manual.html#lua_Alloc

Hmm, the l_alloc function listed there has a matching signature, but different
semantics than described for lua_Alloc.  This confused me.  Perhaps the manual
would be clearer if adjusted as shown in the diff at <http://pastebin.com/t20Pv6FQ>.

Holly