While trying to fix a program of mine (still didn't get there) I came
across:

Dllist *
DLNewList(void)
{
        Dllist     *l;

        l = malloc(sizeof(Dllist));
        l->dll_head = 0;
        l->dll_tail = 0;

        return l;
}

in src/backend/lib/dllist.c, and for a while thought that my problem
had something to do with malloc failing, returning 0, and the next
line trying to write a zero at memory location zero leading to a
segfault. What is the right way of dealing with this? Error message,
or returning NULL a la:

Dllist *
DLNewList(void)
{
        Dllist     *l;

        l = (Dllist *)malloc(sizeof(Dllist));
        if (l != (Dllist *)NULL) {
	        l->dll_head = 0;
		l->dll_tail = 0;
	}
        return l;
}

Again, this wasn't the problem (still looking), but I thought it might
be worth mentioning (same probably applies to DLNewElem()).

Cheers,

Patrick

Tue, 30 Mar 1999 11:09:11 +0100 (BST)
prlw1@cam.ac.uk (Patrick Welche)
dllist.c