Re: xmalloc => pg_malloc - Mailing list pgsql-hackers

From Phil Sorber
Subject Re: xmalloc => pg_malloc
Date
Msg-id CADAkt-gv6GYV7Bt3vjzVTBsqtnnWtSs6P+Z9uRS4SkbtTRx9tA@mail.gmail.com
Whole thread Raw
In response to Re: xmalloc => pg_malloc  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Tue, Oct 2, 2012 at 12:30 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Andres Freund <andres@2ndquadrant.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 think having more than 1 function that does the same thing is
generally a bad idea. It sounds like it is going to cause confusion
and provide no real benefit.

>
>> 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
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: xmalloc => pg_malloc
Next
From: Andres Freund
Date:
Subject: Re: xmalloc => pg_malloc