Re: Move allocation size overflow handling to MemoryContextAllocExtended()?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Move allocation size overflow handling to MemoryContextAllocExtended()?
Дата
Msg-id 960.1475631629@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
Ответы Re: Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2016-10-05 09:38:15 +0900, Michael Paquier wrote:
>> The existing interface of MemoryContextAlloc do not care much about
>> anything except Size, so I'd just give the responsability to the
>> caller to do checks like queue != (Size) queue when queue is a uint64
>> for example.

> Well, that duplicates the check and error message everywhere.

It seems like you're on the edge of reinventing calloc(), which is not an
API that anybody especially likes.  The problem with trying to centralize
overflow handling is that there are too many different cases.  calloc()
handles exactly one case, where the request is to be a product of exactly
two inputs that are individually not capable of overflowing.  As best I
can follow what you've got in mind here, it would be equally likely to
cover only a subset of cases.
        regards, tom lane



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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Is the last 9.1 release planned?
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Declarative partitioning - another take