Guest User

Untitled

a guest
Jun 11th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. ;; struct allocator_std_type
  2. ;; {
  3. ;; void *(*malloc)(size_t);
  4. ;; void *(*realloc)(void *, size_t);
  5. ;; void (*free)(void *);
  6. ;; };
  7.  
  8. ;; void *allocator_create(enum allocator_id allocator_id, void *ctx);
  9.  
  10. (defvar *std-ctx* (foreign-alloc '(:struct allocator-std-type))))
  11.  
  12. (cffi:with-foreign-slots ((malloc realloc free) *std-ctx* (:struct allocator-std-type))
  13. (setf malloc (foreign-symbol-pointer "malloc")
  14. realloc (foreign-symbol-pointer "realloc")
  15. free (foreign-symbol-pointer "free")))
  16.  
Add Comment
Please, Sign In to add comment