Re: adding strndup - Mailing list pgsql-hackers

From Andres Freund
Subject Re: adding strndup
Date
Msg-id 20191204180457.6yo3dhjsmhlj52ky@alap3.anarazel.de
Whole thread Raw
In response to adding strndup  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: adding strndup  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote:
> I just proposed in
> https://postgr.es/m/0191204143715.GA17312@alvherre.pgsql the addition of
> strndup() to our src/port.
> 
> I think this should be pretty uncontroversial, but wanted to give a
> heads-up outside that thread.  I attach the patch here for completeness.

Well, I personally think it's a bad idea to add further implementations
for functions that are in standar libraries on some systems. Especially,
but not exclusively, when made available for frontend code, where it's
not unlikely that there might be other applications having their own
implementations of strndup/whatever.

Besides that reason, I think AC_REPLACE_FUNCS is just a bad mechanism,
that yields fragmented source code and needs to implemented differently
for windows.  The code additionally often will also be badly optimized
in general, due to tiny translation units without relevant functions
having knoweldge about each other.

I'd just provide pnstrdup() in the frontend, without adding strndup().

I also see no point in adding both pnstrdup() and pg_strndup(). I'm fine
with moving towards pg_strndup(), but then we just ought to remove
pnstrdup().

- Andres



pgsql-hackers by date:

Previous
From: Rushabh Lathia
Date:
Subject: Re: backup manifests
Next
From: Robert Haas
Date:
Subject: Re: backup manifests