[plt-scheme] Testing a pointer for null (FFI)
Hi all,
How does one test a pointer for null using the foreign
library? In this situation I malloc the pointer (a
_pointer if that matters) and pass it to a library function
(SQLite) which initialises it. Sometimes an error occurs
and the pointer gets set to null.
I've printed out the following:
the pointer: #<cpointer>
(ptr-equal? the-pointer #f): #f
(ptr-ref the-pointer _int): 0
Now I could convert the pointer to an integer and compare
to zero, but this seems very hacky. Surely there is a
better way?
BTW, the library I'm using is Jay's SQLite bindings. I'm
passing an empty string to prepare. SQLite doesn't signal
an error (though it should -- if you try to use the
statement it does raise an error). [Jay: don't bother
updating your copy; I've made many changes and will send an
updated version your way once I've finished.]
Thanks,
Noel
Email: noelwelsh <at> yahoo <dot> com noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/ http://www.untyped.com/untyping/
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com