[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: cleanup in a C module
- From: "Andreas K. Foerster" <list@...>
- Date: Wed, 23 Jun 2010 09:16:47 +0200
I'm new to Lua. So bear with me if my questions are a little stupid.
But I have some problems with it for which I couldn't find a proper
First what I have: I have written a library, AKFAvatar, that is based on SDL.
Now I want it to be scriptable with Lua. It already works to a large extent.
One problem is, how can I cause the Lua script to return successfully, ie. without
an error, from within the C code? I don't want to put the burden to check for
conditions on the Lua programmer, so I want to do it from the C code.
My workaround for now is, that I use the function lua_error(), but instead of an
error message I simply push a nil to the stack, and the calling program checks for
that and reacts accordingly. That works, but there is surely a better solution,
Then I wanted to compile the language binding as a module. That works fine as
long as it runs. But I have the problem, that I don't know how to do the
In the application I simply register the cleanup function with atexit(3).
But when I use atexit inside the module it just hangs at the end.
Well, the SDL documentation says: "using atexit in a library is a sure way to
crash dynamically loaded code". But what else can I use?
(By the way, that problem already appeared before I did the workaround
described above. So there is no connection.)
If you want to have a look at my code, the Lua-specific parts are there:
Homepage of AKFAvatar: