7
NOTE: Let Racket GC manage your FFI object
source link: https://dannypsnl.github.io/blog/2022/01/22/cs/racket-ffi-gc/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
All you need are deallocator and allocator from .NOTE: Let Racket GC manage your FFI object
Email: [email protected]
GitHub: @dannypsnl
Twitter: @dannypsnl
Programming Language Theory • System Programming
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))
author: Lîm Tsú-thuàn/林子篆/Danny
category:cs
tag:noteffigcracket
Similar Articles
All works in this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.©2022 dannypsnl(林子篆)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK