Subject: [clisp-list] Re: ffi, clisp and dll's

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Thu Mar 11 09:02:10 2004

Hi,

Pieter asked in comp.lang.lisp about closing dynamic libraries:
> I am working on windows xp with clisp.
> 
> I just wrote a little dll with visual studio and I managed to do a 
> (ffi:def-call-out) on it. It loaded it right, executed the function 
> which I specified and I am extremely happy about it :)
> 
> My question: Is there a way to release this dll from within clisp or 
> lisp code? I recompiled the .dll and tried to copy it to the working 
> lisp directory, but couldn't because of the fact that the old .dll was 
> still in use.

CLISP doesn't come with a function to unlink a foreign library.
Yet I believe you could come up with code which achieves this goal if you can
1. find the MS-windows dll which contains the CloseLibrary (name?) call
2. invoke that with your #<foreign-pointer> to your .dll
3. invoke (setf (validp #<foreign-pointer to your library>) nil)

Basically, it's doing the job of unlinking the library by hand, using the FFI itself.

Next time FFI::FOREIGN-LIBRARY will be called (e.g. via
FFI:DEF-CALL-OUT), IIRC, CLISP should open the library again because it sees the defunct pointer.

[Could somebody kindly confirm privately that this e-mail to clisp-users also made it to the whole of the Usenet community reading comp.lang.lisp?]

Regards,
	Jorg Hohle