3 ms·
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/a636578fe
by dietr1ch 4y ago
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/a636578fe9f06faa5d46e1b78aa7ba4e/revisions https://gist.github.com/Dietr1ch/a636578fe9f06faa5d46e1b78aa...
- edflsafoiewq 4y agoWhen 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-to-remove-item-from-singly-linked-list https://stackoverflow.com/questions/12914917/using-pointers-....