how copying works (3)
initially
- both point to beginning of free memory
first step
- pair pointed to by root is copied to free memory
- root pointer is adjusted to point to new location & free pointer is incremented
- old location of pair is made into a broken heart
repeatedly
- scan points to pair just relocated
relocate this pair’s car and cdr objects & increment scan
- to relocate
if already movedreplace pointer in pair being scanned by forwarding address
if not already movedcopy to place indicated by free & increment freeset up broken heart at old locationupdate pointer to point to new location
until
- all accessible objects have been moved: free and scan coincide again