SystemCall run(block) can now exit the run if it returns false
[io/quag.git] / libs / garbagecollector / source / CollectorMarker.c
blob06a942e2662517adb3b3932a27fb401397d65021
1 #define COLLECTORMARKER_C
2 #include "CollectorMarker.h"
3 #undef COLLECTORMARKER_C
5 #include <assert.h>
7 void CollectorMarker_check(CollectorMarker *self)
9 CollectorMarker *v = self;
11 while (v != self)
13 assert(v->next->prev == v);
14 assert(v->prev->next == v);
15 v = v->next;
19 CollectorMarker *CollectorMarker_new(void)
21 CollectorMarker *self = io_calloc(1, sizeof(CollectorMarker));
22 return self;
25 CollectorMarker *CollectorMarker_newWithColor_(unsigned int color)
27 CollectorMarker *self = CollectorMarker_new();
28 self->color = color;
29 return self;
32 void CollectorMarker_free(CollectorMarker *self)
34 io_free(self);
37 void CollectorMarker_loop(CollectorMarker *self)
39 self->prev = self;
40 self->next = self;
43 int CollectorMarker_count(CollectorMarker *self)
45 int count = 0;
46 CollectorMarker *v = self->next;
47 unsigned int c = self->color;
49 while (v->color == c)
51 CollectorMarker *next = v->next;
52 v = next;
53 count ++;
56 return count;
59 int CollectorMarker_colorSetIsEmpty(CollectorMarker *self)
61 return self->color != self->next->color;