UP | HOME

NOTE: Let Racket GC manage your FFI object

All you need are deallocator and allocator from ffi/unsafe/alloc.

(require ffi/unsafe
	 ffi/unsafe/define
	 ffi/unsafe/alloc)

(define-ffi-definer define-xxx
  (ffi-lib "<path to your libxxx>" '(#f)))

(define-xxx free-yyy (_fun _YyyRef -> _void)
  #:c-id yyy_delete
  #:wrap (deallocator))
(define-xxx make-yyy (_fun -> _YyyRef)
  #:c-id yyy_new
  #:wrap (allocator free-yyy))

Date: 2022-01-22 Sat 00:00

Author: Lîm Tsú-thuàn