When an object O is deleted, it needs to be removed from the linked list by patching the pointer that led to O to lead to O->next instead. There are two cases: for the first object in the list, you need to patch vm->firstObject; for the rest, you need to patch prevObject->next. You can unify these cases by storing a pointer to the pointer you need to patch, ie. a pointer to the pointer that led to O.
Comments
Nice read. BTW, is there any reason to implement sweep with an Object** instead of just an Object*?
edit: Like this, https://gist.github.com/Dietr1ch/a636578fe9f06faa5d46e1b78aa...
When an object O is deleted, it needs to be removed from the linked list by patching the pointer that led to O to lead to O->next instead. There are two cases: for the first object in the list, you need to patch vm->firstObject; for the rest, you need to patch prevObject->next. You can unify these cases by storing a pointer to the pointer you need to patch, ie. a pointer to the pointer that led to O.
See also https://stackoverflow.com/questions/12914917/using-pointers-....