[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] lrexlib 2.7.2 released
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 9 Jan 2013 22:38:03 -0200
> is there an easy way to convert from malloc and free to using the Lua allocator? Some macros perhaps? Any example code?
#define LUA_ALLOC(p,size) lua_getallocf(L,NULL)(NULL,p,0,size)
#define malloc(size) LUA_ALLOC(NULL,size)
#define free(p) LUA_ALLOC(p,0)
#define realloc(p) LUA_ALLOC(p,size)
This code assumes a Lua state named L in the scope. If that is not the case,
fix LUA_ALLOC.