lua-users home
lua-l archive

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


Exactly what I was looking for, thank you!

Np.

I'm just starting with Lua embedding, but what use does lua_setallocf have? It seems extremely dangerous in general due to the potential allocator mismatch issue.

Not much, but it's a simple function to be implemented that may be useful for some people. ie, you could use a regular allocator for most allocs, but on a lua function call swap in a tracing garbage collector which reports when memory is resized/freed etc. As long as both allocators are compatible, no harm in swapping them. Similarly you may keep the current allocator but merely change the UD pointer (which may not be a pointer at all, perhaps just an enumeration typecast to a pointer). Off the top of my head.

- Alex