From owner-freebsd-arch@FreeBSD.ORG Thu Dec 4 18:44:37 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E7131065670 for ; Thu, 4 Dec 2008 18:44:37 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.delphij.net (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id AA8668FC1F for ; Thu, 4 Dec 2008 18:44:36 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [211.166.10.233]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.delphij.net (Postfix) with ESMTPS id DF7E828448 for ; Fri, 5 Dec 2008 02:44:35 +0800 (CST) Received: from localhost (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id 825C0EB9E54; Fri, 5 Dec 2008 02:44:35 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by localhost (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with ESMTP id 5WEjYgpDbbYh; Fri, 5 Dec 2008 02:44:30 +0800 (CST) Received: from charlie.delphij.net (adsl-76-237-33-62.dsl.pltn13.sbcglobal.net [76.237.33.62]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id 8324BEB9E3C; Fri, 5 Dec 2008 02:44:29 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=epaD02h7TA+jrOiiGsIAGuWsF++RjqFusR/2nQR+LxzFGjNNtH9u6+pYqN/jw1t3k dvd8kXtSebiXkvUbXTqvg== Message-ID: <49382502.1040403@delphij.net> Date: Thu, 04 Dec 2008 10:44:18 -0800 From: Xin LI Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Florian Smeets References: <49381DD4.2000506@kasimir.com> In-Reply-To: <49381DD4.2000506@kasimir.com> X-Enigmail-Version: 0.95.7 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: Adding strndup(3) to libc viable/useful? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2008 18:44:37 -0000 -----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 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-----