News for hackers. Stuff that matters.
Re:Garbage Collection by a1369209993 on Sunday December 01, 2019 @01:36AM (#21674200)

  > if (previous != NULL) {
  >   previous->next = object;
  > } else {
  >   vm.objects = object;
Ergh. That's much more painful than it needs to be. Maybe try:

  static void sweep() {
    Obj** ref = &vm.objects;
    while (*ref != NULL) {
      if ((*ref)->isMarked) {
        (*ref)->isMarked = false;
        ref = &(*ref)->next;
      } else {
        Obj* unreached = *ref;
        *ref = unreached->next;
        freeObject(unreached);
      }
    }
  }
Re:Garbage Collection by 1f60c on Sunday December 01, 2019 @08:16AM (#21675339)
Funny you might say that.

Baby’s First Garbage Collector[0] (from the same author) uses this approach.

[0]: https://journal.stuffwithstuff.com/2013/12/08/babys-first-ga...