From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Andres Freund <andres(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Safe memory allocation functions |
Date: | 2015-01-27 08:27:53 |
Message-ID: | CAB7nPqQS4A4B9HsxXfRJoiy2v5-iN8k+=Bam0FcOX_5MCX3xhw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera wrote:
>> So how about something like
>>
>> #define ALLOCFLAG_HUGE 0x01
>> #define ALLOCFLAG_NO_ERROR_ON_OOM 0x02
>> void *
>> MemoryContextAllocFlags(MemoryContext context, Size size, int flags);
The flag for huge allocations may be useful, but I don't actually see
much value in the flag ALLOC_NO_OOM if the stuff in aset.c returns
unconditionally NULL in case of an OOM and we let palloc complain
about an OOM when allocation returns NULL. Something I am missing
perhaps?
>> I definitely do not want to push the nofail stuff via the
>> MemoryContextData-> API into aset.c. Imo aset.c should always return
>> NULL and then mcxt.c should throw the error if in the normal palloc()
>> function.
>
> Sure, that seems reasonable ...
Yes, this would simplify the footprint of this patch to aset.c to a
minimum by changing the ereport to NULL in a couple of places.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-01-27 08:34:14 | Re: Safe memory allocation functions |
Previous Message | Andreas Karlsson | 2015-01-27 08:21:48 | Re: Using 128-bit integers for sum, avg and statistics aggregates |