Re: pg_malloc() versus malloc(0)

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: pg_malloc() versus malloc(0)
Дата
Msg-id m2pq52uuxi.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на pg_malloc() versus malloc(0)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: pg_malloc() versus malloc(0)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:
> 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.

What's the use case for malloc(0) anyway?

> 1. Teach pg_malloc not to complain if result == NULL and size == 0.

What about not calling malloc at all in such places? Well I guess what
you want is for the pg_malloc() API to be able to never return NULL…

> 2. Before the malloc call, have it replace size == 0 with size = 1.

As I don't understand the need to malloc 0 byte I would think that's ok
as a way to simplify code…

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Hash id in pg_stat_statements
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Extending range of to_tsvector et al