Guest User

Untitled

a guest
Jun 12th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 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. ;; definition created by c2ffi
  11. ;; (CFFI:DEFCSTRUCT (ALLOCATOR-STD-TYPE :SIZE 24)
  12. ;; (MALLOC FUNCTION-POINTER :OFFSET 0)
  13. ;; (REALLOC FUNCTION-POINTER :OFFSET 8)
  14. ;; (FREE FUNCTION-POINTER :OFFSET 16))
  15.  
  16. (defvar *std-ctx* (foreign-alloc '(:struct allocator-std-type))))
  17.  
  18. (with-foreign-slots ((malloc realloc free) *std-ctx* (:struct allocator-std-type))
  19. (setf malloc (foreign-symbol-pointer "malloc")
  20. realloc (foreign-symbol-pointer "realloc")
  21. free (foreign-symbol-pointer "free")))
  22.  
Add Comment
Please, Sign In to add comment