News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
Alien segfaults
Author Message

Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
RE: Alien segfaults

I totally fogot to say, that "getsym(nil,"COLS")" and "getsym(nil,"LINES")" are two expensive operations and you have to use them only once. They are only necessary to get the memory location (pointer) where the "COLS" and "LINES" values are stored. The location in memory does not change. So it would make more sense to put those lines on top after the alien.load(""):

getsym=alien.default.dlsym -- give it a shorter name
-- dlsym searches for the symbol name given as second parameter.
-- The first parameter is a pointer to the location where the library has been loaded.
-- dlsym returns a pointer to the symbol.
-- We have no pointer to the ncurses library.
-- Unfortunately there is no way to get that information from alien. But it doesn't matter,
-- the linker can find it nevertheless, because alien did load it with the global option enabled.
-- Therfore it is enough to us a NULL pointer (you have to use nil in lua, 0 won't do it).

-- ncurses has to be called to fill the variables with meaningfull values.

print("The terminal has "..alien.toint(colons).." cols and "..alien.toint(lines).." lines")
-- Since we have the pointers to the global variables/memory locations (wrapped in Lua userdata),
-- we can dereference it any time we want.


01-11-2009 03:05 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
Alien segfaults - jpjacobs - 01-09-2009, 01:41 AM
RE: Alien segfaults - jpjacobs - 01-09-2009, 06:06 AM
RE: Alien segfaults - Juergen - 01-10-2009, 10:36 AM
RE: Alien segfaults - jpjacobs - 01-10-2009, 10:06 PM
RE: Alien segfaults - Juergen - 01-11-2009 03:05 AM
RE: Alien segfaults - jpjacobs - 01-11-2009, 04:40 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: