Re: Safe memory allocation functions - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Safe memory allocation functions
Date
Msg-id 20150127083413.GJ4655@awork2.anarazel.de
Whole thread Raw
In response to Re: Safe memory allocation functions  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Safe memory allocation functions
List pgsql-hackers
On 2015-01-27 17:27:53 +0900, Michael Paquier wrote:
> 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 guess the idea is to have *user facing* MemoryContextAllocExtended()
that can do both huge and no-oom allocations. Otherwise we need palloc
like wrappers for all combinations.
We're certainly not just going to ignore memory allocation failures
generally in in MemoryContextAllocExtended()....

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Safe memory allocation functions
Next
From: Abhijit Menon-Sen
Date:
Subject: Re: pgaudit - an auditing extension for PostgreSQL