Subject: [clisp-list] FFI - Creating c-places in LISP?

From: "Dave Richards" <[email-masked]>
Date: Mon Sep 30 22:31:01 2002

I have decided to take a different approach to implementing my TCP-based
server.  Rather than use the socket server/stream classes, I am going to try
accessing the socket calls directly.  This is how CMUCL handles the problem
and my early tests on CMUCL have been quite favorable.  Which leads to my
question:

	Is it possible in the FFI to define a c-struct (def-c-struct) then create
an instance of it in LISP, initialize it, then pass a pointer to it via FFI?
I guess what I am asking is whether it's possible to allocate a c-place
inside the LISP heap.
	My reading of the implementation notes imply that "c-places" originate
outside the LISP heap, i.e. have static storage class.  One could infer that
C code could malloc() a region and return this, but how then do we ensure
free() is called at GC finalization?

	Dave

---

From: "Dave Richards" <[email-masked]>
Date: Tue Oct 1 06:04:02 2002

> free() is called at GC finalization?

Ah!  WITH-FOREIGN-OBJECT.  That'll do it.

---

From: "Dave Richards" <[email-masked]>
Date: Tue Oct 1 08:51:54 2002

> Ah!  WITH-FOREIGN-OBJECT.  That'll do it.

Hmm.  It's in the document, but not in FFI:.

	[14]> (apropos "foreign-object")

	[15]> 

Is there another methof for declaring c-places in LISP?