lua-users home
lua-l archive

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

To complement the reply given by lhf:

- you must be very careful when using lbuffer.c's functions. Lua itself 
uses this buffer for many tasks, so it is not safe to call Lua while using 
this buffer (unless you create a "new" buffer; see, for instance, 
lstrlib.c->add_s, that calls a Lua function in the middle of a gsub). 

- By the same token, you must be careful when using dynamic memory inside 
Lua, because Lua uses longjmp in case of errors; that may create memory 
leaks in your implementation. (For instance, luaL_verror is a function that 
never returns, an so would never free a dynamically allocated buffer.) 

- you cannot free variable ldo.c->lua_dofile():source before calling 
do_main. luaZ_Fopen puts a pointer to this variable inside the structure 
ZIO z. (However, you should be able to set -DMAXFILENAME=60 or other 
smaller limit; we will fix that for the next version.) 

- You can reduce the memory used by FuncState if you define smaller limits 
for some arrays: For instance, -DMAXLOCALS=50 and -DMAXUPVALUES=8 is more 
than enough for most applications. Moreover, the memory used by LexState 
will be reduced in next version with the end of $if. 

-- Roberto