logo       

:malloc-free allocation -- here: instance methods: msg#00072

lisp.clisp.general

Subject: :malloc-free allocation -- here: instance methods

Hoehle, Joerg-Cyril writes:

> However, duplicating the DB structure in Lisp, if the BDB C
> structure changes, Lisp doesn't know -- not nice! Unreliable :(

this problem could be solved by a program that translates C
declarations into FFI declarations. Such a program is available for
some Common Lisp implementations, e.g LispWorks.

> [memoizing-]DB-foreign-function-factory could be implemented in C,
> to avoid the problem about the C DB struct being changed by the BDB
> people, without Lisp noticing this change. This would prevent
> getting out of sync with BDB/ db.h

returned function prototype could be a problem: every DB fuction has
its own parameter list. Probably the C factory function should return
a c-pointer which has to be casted to the appropriate FFI:C-FUNCTION
type before APPLYing it.

Another solution could be a C program which, using the offsetof macro,
prints the offset of the relevant DB function pointer members. Its
output could be used to create defconstants in a Lisp file. At
runtime, using FFI:OFFSET and the offset constants, it should be
possible to extract a foreign function pointer from a DB
pointer. Details are left to the reader as exercise :)



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise