Source
(defmethod initialize-instance :after ((heap free-list-heap)
&key &allow-other-keys)
;; Initialize the heap end.
(if (zerop (file-length (heap-stream heap)))
(setf (heap-end heap) +pointer-size+)
(setf (slot-value heap 'end) (pointer-value 0 heap)))
;; Load or create the array of free list pointers.
(setf (slot-value heap 'starts)
(make-array (nr-free-lists heap)))
(cond ((< (heap-end heap) (heap-start heap))
;; The free list array doesn't exist yet: create free lists.
;; Initialize the free list array by letting the free-list pointers
;; point to themselves (meaning that the free list is empty).
(loop for size-class below (nr-free-lists heap)
do (setf (free-list-start heap size-class)
(free-list-pointer size-class)))
;; Set heap-end just after the free list array.
(setf (heap-end heap) (heap-start heap)))
(t
;; Heap exists: load free lists.
(let ((array (slot-value heap 'starts)))
(loop for size-class below (nr-free-lists heap)
do (setf (aref array size-class)
(pointer-value (free-list-pointer size-class)
heap)))))))
Source Context