From owner-freebsd-questions@FreeBSD.ORG Mon Apr 14 23:50:30 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7750A106566C for ; Mon, 14 Apr 2008 23:50:30 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id E11878FC12 for ; Mon, 14 Apr 2008 23:50:29 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl118-36.kln.forthnet.gr [77.49.237.36]) (authenticated bits=128) by igloo.linux.gr (8.14.2/8.14.2/Debian-3) with ESMTP id m3ENoFkJ025001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 15 Apr 2008 02:50:22 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m3ENoF8E013450; Tue, 15 Apr 2008 02:50:15 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m3ENoEc3013449; Tue, 15 Apr 2008 02:50:14 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: stevefranks@ieee.org References: <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com> <877if0qbnz.fsf@kobe.laptop> <539c60b90804141627r502ec7eeudd5b3112cd891ed@mail.gmail.com> Date: Tue, 15 Apr 2008 02:50:14 +0300 In-Reply-To: <539c60b90804141627r502ec7eeudd5b3112cd891ed@mail.gmail.com> (Steve Franks's message of "Mon, 14 Apr 2008 16:27:42 -0700") Message-ID: <87y77gov2h.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: m3ENoFkJ025001 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.903, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.50, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: FreeBSD Mailing List Subject: Re: [?OT?] strndup exists in FreeBSD? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2008 23:50:30 -0000 On Mon, 14 Apr 2008 16:27:42 -0700, "Steve Franks" wrote: >> While it seems like a cool function name, what's the point of having it? >> If you know how much you want to copy, it's trivial to allocate a buffer >> large enough and strlcpy() into it. If you don't know how much you want >> to copy, then strdup() is ok anyway :) > > Granted. It's just one more thing to hack when porting linux code > (which I'm getting rather tired of doing, I must admit - they seem to > assume everyone likes to include every new api ever concieved, then > they go off and use them...) Ah, I see now. I think I know the feeling... I just saw a diff fly by at the review emails at work, which replaced strlcpy() with strncpy() because of a similar problem, only this time the other way around. The libc of BSD and Solaris includes strlcpy() and strlcat(), but it's unavailable in Linux, so we have to either "hack around" the missing feature with strncpy() or conditionally include a BSD licensed version of strlcpy() to our compatibility cruft. ``Portability is a huge chimera.'' Oh well :(