PrevNextAll


Debugging data structures

Write a structure checker

void checkasylist(NODE **head)
{
 NODE **prev = head;
 for (;;) {
 	NODE *t = *prev;
	if (!t) return;
	if (t->prev != prev) {
		fprintf(stderr, "Bad prev: %p->prev = %p, should be %p\n",
			t, t->prev, prev);
		abort();
	}
	prev = &t->next;
	t = t->next;
 }
}
	.
	.
	.

		// jobs is full initialised, ready to run
	asy_insert(&jobq, job);
	checkasylist(&jobq);
	.
	.
	.