lua-users home
lua-l archive

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


----- Original Message -----
From: Martin
Date: 9/3/2008 7:41 PM
One thing that bother me is that I can not find why game always end
with segmentation fault when I am closing it! What is strange it
segfault after last command in the game is executed. I strongly
suspect it has to do something with memory management but can not
figure out a cure. Any suggestion?
I have a slightly modified version of Alien. It runs your sample fine. Among other fixes, it has this in core.c:

static int alien_function_gc(lua_State *L) {
 alien_Function *af = alien_checkfunction(L, 1);
 if(af->name) free(af->name);
 if(af->params) {
   free(af->params);
   if(af->ffi_params) free(af->ffi_params);
 }
 return 0;
}

The rest of my fixes can be found at svn://svn.luaplus.org/LuaPlus/work51/Src/Modules/alien/src/core.c and struct.c.
And lastly when I allocate a buffer with alien.buffer() how do I free
it?  I guess this can be reason why my program ends with segmentation
fault, because I allocate buffers on several places but never free any
of them. Or does garbage collector take care of them?
It is garbage collected.

Josh