Skip site navigation (1) Skip section navigation (2)

Re: xmalloc => pg_malloc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: xmalloc => pg_malloc
Date: 2012-10-02 16:30:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> pg_calloc	(randomly different API for pg_malloc0)

> Do we need this?

I thought about getting rid of it, but there are some dozens of calls
scattered across several files, so I wasn't sure it was worth it.
Anybody else have an opinion?

> I wonder whether the same set of functions should also be available in the 
> backend with ereport(EC_OUT_OF_MEMORY, ...) behaviour as well.

In the backend, you almost always ought to be using palloc instead.
The only places where it's really appropriate to be using malloc
directly are where you don't want an error thrown for out-of-memory.
So I think providing these in the backend would do little except to
encourage bad programming.

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Phil SorberDate: 2012-10-02 16:44:26
Subject: Re: xmalloc => pg_malloc
Previous:From: Bruce MomjianDate: 2012-10-02 16:21:34
Subject: Re: xmalloc => pg_malloc

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group