Re: [PATCH] Add use of asprintf() - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [PATCH] Add use of asprintf()
Date
Msg-id 20130916203137.GB4991@eldon.alvh.no-ip.org
Whole thread Raw
In response to [PATCH] Add use of asprintf()  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: [PATCH] Add use of asprintf()
Re: [PATCH] Add use of asprintf()
List 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



pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: Updatable view columns
Next
From: Yeb Havinga
Date:
Subject: Re: Possible memory leak with SQL function?