lua-users home
lua-l archive

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


Hi,

For some reason the tarball on LuaForge was different from the version
in the repo (this is not supposed to happen as I have a make target
that packages and uploads the repo, but alas...), so this small bug
got away. It's fine now, so another "luarocks install alien" and the
example will run without glitches (apart from Ubuntu calling the
blasted lib libSDL-1.2.so instead of libSDL.so.1.2).

Joshua, could you explain what you use the type "cfunction" for? Maybe
I can overload one of the current types (pointer or callback) to do
what it does, instead of adding yet another one... and what about the
changes to struct (the "I" format and the extra parameter to userdata
unpacking)?

About signed vs unsigned, I wanted to see how far I could go without
adding this extra cruft (apart from the inevitable case of char vs
byte). In your SDL_FIllRect example, for example, you can use this as
prototype to SDL_MapRGBA:

SDL.SDL_MapRGBA:types("int", "pointer", "char", "char", "char", "char")

and then declare the last type of FillRect as int. It will all work
out in the end. It will even work if you build it in Lua "by hand"
(using bitlib) and then pass as a regular (signed) int.

--
Fabio Mascarenhas

On Wed, Sep 3, 2008 at 11:42 PM, Joshua Jensen
<jjensen@workspacewhiz.com> wrote:
> ----- 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
>
>