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

Re: xmalloc => pg_malloc

From: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: xmalloc => pg_malloc
Date: 2012-10-04 14:19:32
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Wed, Oct 3, 2012 at 11:36 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> xmalloc, xstrdup, etc. are pretty common names for functions that do
>> alloc-or-die (another possible naming scheme ;-) ).  The naming
>> pg_malloc etc. on the other hand suggests that the allocation is being
>> done in a PostgreSQL-specific way, and anyway sounds too close to
>> palloc.
>> So I'd be more in favor of xmalloc <= pg_malloc.
> Meh.  The fact that other people use that name is not really an
> advantage from where I sit.  I'm concerned about possible name
> collisions, eg in libraries loaded into the backend.
> There are probably not any actual risks of collision right now, given
> that all these functions are currently in our client-side programs ---
> but it's foreseeable that we might use this same naming convention in
> more-exposed places in future.  In fact, somebody was already proposing
> creating such functions in the core backend.
> But having said that, I'm not absolutely wedded to these names; they
> were just the majority of existing cases.

Why not split the difference and use pg_xmalloc?
As in: "PostgreSQL-special malloc that dies on failure."


In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2012-10-04 14:32:59
Subject: Re: Raise a WARNING if a REVOKE affects nothing?
Previous:From: Amit KapilaDate: 2012-10-04 13:52:07
Subject: Re: Switching timeline over streaming replication

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