dllist.c

From: prlw1(at)cam(dot)ac(dot)uk (Patrick Welche)
To: pgsql-hackers(at)postgresql(dot)org
Subject: dllist.c
Date: 1999-03-30 10:09:11
Message-ID: E10RvSJ-0000yE-00@taurus.cus.cam.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Samersoff 1999-03-30 10:58:51 Re: [HACKERS] libpq++
Previous Message Peter Mount 1999-03-30 10:00:09 RE: [HACKERS] Create user is failing under 6.5