pg_malloc() versus malloc(0)
От | Tom Lane |
---|---|
Тема | pg_malloc() versus malloc(0) |
Дата | |
Msg-id | 23126.1349100046@sss.pgh.pa.us обсуждение исходный текст |
Ответы |
Re: pg_malloc() versus malloc(0)
Re: pg_malloc() versus malloc(0) |
Список | pgsql-hackers |
Per http://archives.postgresql.org/pgsql-general/2012-10/msg00013.php we have got a problem with the pg_malloc() interface functions that were recently added to pg_dump and a lot of other frontend code. Namely, that on platforms where malloc(0) returns NULL instead of a pointer to a zero-size block, pg_malloc thinks it's a failure and aborts the program. There are basically two ways we could fix this: 1. Teach pg_malloc not to complain if result == NULL and size == 0. 2. Before the malloc call, have it replace size == 0 with size = 1. #2 would guarantee no NULL returns from pg_malloc, which would be closer to the behavior of palloc in the backend. On the other hand, it seems a bit wasteful and inelegant. Any code that was capable of calling malloc(0) before is presumably not going to be upset by a NULL return, or we'd have seen trouble reports sooner. Any opinions which way to go? I'm not convinced either way yet. regards, tom lane
В списке pgsql-hackers по дате отправления: