Re: Move allocation size overflow handling to MemoryContextAllocExtended()? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Move allocation size overflow handling to MemoryContextAllocExtended()?
Date
Msg-id 960.1475631629@sss.pgh.pa.us
Whole thread Raw
In response to Re: Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
Responses Re: Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
List 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 by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Is the last 9.1 release planned?
Next
From: Robert Haas
Date:
Subject: Re: Declarative partitioning - another take