On Tue, Feb 5, 2013 at 12:18 AM, Phil Sorber <p...@omniti.com> wrote:
> On Mon, Feb 4, 2013 at 10:52 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
>> Phil Sorber <p...@omniti.com> writes:
>>> get_progname() returns a strdup()'d value. Shouldn't it then be simply
>>> char * and not const char *? Otherwise free() complains loudly without
>>> a cast.
>>
>> I don't believe that callers should be trying to free() the result.
>> Whether it's been strdup'd or not is not any of their business.
>
> Is that just because of the nature of this specific function?

I can't presume to speak for Tom, but I think so.  Sometimes the API
of a function includes the notion that the caller should pfree the
result.  Sometimes it doesn't.  The advantage of NOT including that in
the API contract is that you can sometimes do optimizations that would
be impossible otherwise - e.g. you can return the same palloc'd string
on successive calls to the function; or you can sometimes return a
statically allocated string.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to