dllist.c
| От | prlw1@cam.ac.uk (Patrick Welche) |
|---|---|
| Тема | dllist.c |
| Дата | |
| Msg-id | E10RvSJ-0000yE-00@taurus.cus.cam.ac.uk обсуждение исходный текст |
| Список | 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
В списке pgsql-hackers по дате отправления: