lua-users home
lua-l archive

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


> [Although this question was not asked on lua-l, I thought it would be good
> to send a reply there.] lrexlib 2.7.x uses, where possible, the Lua
> state's allocator, rather than malloc. This is done because it seems to me
> this is what one would expect: if one chooses a different allocator for
> one's Lua state, e.g. for debugging or performance reasons, then it should
> be used for everything.
> 
> Unfortunately, it's not possible to use it for absolutely everything,
> because some memory is allocated and/or freed by a given regex library.
> I notice now that PCRE allows its allocator functions to be overridden, so
> I shall do that; unfortunately, GNU, POSIX, oniguruma and TRE all don't.

Is this generally considered good practice? The thought never crossed my mind.
Anyone else doing this, or explicitly not doing this?

Haven't looked into it yet, but is there an easy way to convert from malloc and free to using the Lua allocator? Some macros perhaps? Any example code?

Thijs