Adding strndup(3) to libc viable/useful?

Xin LI delphij at delphij.net
Thu Dec 4 10:44:37 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, Florian,

Florian Smeets wrote:
> Hi,
> 
> first of all i hope arch is the correct place to discuss this.
> 
> While porting an application to FreeBSD i found that FreeBSDs libc does
> not have strndup. NetBSD added this about 2 years ago. A port of this to
> FreeBSD was very easy.
> 
> There are 13 ports in the ports tree right now that patch in strndup via
> a patch in the files/ dir, well actually 12 bring there own version of
> strndup and one replaces it with a call to malloc/strncpy.
> 
> Would it make sense to add this to our libc? A patch which does this is
> available here at http://webmail.solomo.de/~flo/strndup.patch
> 
> I don't know if there is such a thing as minimum number of ports to
> require a function so that it can be added to the base system...
> 
> Any feedback appreciated.

I think whether or not to add it really depends on how popular it is :)
 We included strdup() because it is a very common extension.

Your patch looks fine but perhaps it would be a good idea to explicitly
mention that this is not a commonly implemented GNU extension
(inheritedly, this could reduce portability).

Cheers,
- --
Xin LI <delphij at delphij.net>	http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkk4JQEACgkQi+vbBBjt66BNKwCgtLMQccFG6VvPv2xLjsmZr7I5
VuEAnjiCRzKtuhmMHHzuwrBibKGluidX
=Y4XX
-----END PGP SIGNATURE-----


More information about the freebsd-arch mailing list