Re: [PATCH] Add use of asprintf()

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add use of asprintf()
Date: 2013-09-16 20:31:37
Message-ID: 20130916203137.GB4991@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:

> The attached patch should speak for itself.

Yeah, it's a very nice cleanup.

> I have supplied a few variants:
>
> - asprintf() is the standard function, supplied by libpgport if
> necessary.
>
> - pg_asprintf() is asprintf() with automatic error handling (like
> pg_malloc(), etc.)
>
> - psprintf() is the same idea but with palloc.

Looks good to me, except that pg_asprintf seems to be checking ret
instead of rc.

Is there a reason for the API discrepancy of pg_asprintf vs. psprintf?
I don't see that we use the integer return value anywhere. Callers
interested in the return value can use asprintf directly (and you have
already inserted callers that do nonstandard things using direct
asprintf).

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yeb Havinga 2013-09-16 20:38:13 Re: Possible memory leak with SQL function?
Previous Message Marko Tiikkaja 2013-09-16 20:14:47 Re: Updatable view columns