lua-users home
lua-l archive

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


On Tuesday 29 March 2011 19:30:33 Roberto Ierusalimschy wrote:
> > when porting a program from Lua 5.1 to Lua 5.2, I experienced crashes
> > within my custom memory allocator function, which I passed to
> > lua_newstate.
> > 
> > I finally found out that the expected behaviour of the allocator function
> > has changed in Lua 5.2. See:
> > http://www.lua.org/work/doc/manual.html#lua_Alloc
> > 
> > Unfortunatly this is not documented in the list of changes in the API:
> > http://www.lua.org/work/doc/manual.html#8.3
> > 
> > I suggest to add this missing information in Section 8.3 of the manual.
> 
> Thanks. We will correct that.
> 
> -- Roberto

My own lua_Alloc function started with code similar to the following:

if ((*counter + nsize - osize) > PGLUA_MEMORYLIMIT) return NULL;
*counter += nsize - osize;

I realized that due to the new interface I need to make another distinction of 
cases to track memory usage (depending on what osize really means). According 
to my own (personal) taste, it would be nice to have an extra argument passed 
to the lua_Alloc function, instead of (ab)using osize for that. Old code may 
be broken anyway due to the subtle changes, which have been already 
introduced.


Regards
Jan Behrens