ffi: fix size-of-foreign-type when called on structore with no slots

Fixes #752.
This commit is contained in:
Daniel Kochmański 2024-06-21 21:43:43 +02:00
parent f5e3de23fd
commit 4f0fed4698

View file

@ -71,14 +71,15 @@ does not include any Lisp storage overhead."
((atom type)
(error "~A is not a valid foreign type identifier" name))
((eq (setf name (first type)) :struct)
(setf size (slot-position type nil)
align (apply #'max (mapcar #'(lambda (field)
(multiple-value-bind (field-size field-align)
(size-of-foreign-type (second field))
(declare (ignore field-size))
field-align))
(rest type))))
(%align-data size align))
(setf size (slot-position type nil))
(when (rest type)
(setf align (apply #'max (mapcar #'(lambda (field)
(multiple-value-bind (field-size field-align)
(size-of-foreign-type (second field))
(declare (ignore field-size))
field-align))
(rest type))))
(%align-data size align)))
((eq name :array)
(unless (and (setf size (third type)) (realp size))
(error "Incomplete foreign type: ~S" type))