From owner-freebsd-questions@FreeBSD.ORG Mon Apr 14 23:06:54 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 1A0B81065671 for ; Mon, 14 Apr 2008 23:06:54 +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 6C56B8FC21 for ; Mon, 14 Apr 2008 23:06:53 +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 m3EN6VO7022810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 15 Apr 2008 02:06:37 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m3EN6VNn002666; Tue, 15 Apr 2008 02:06:31 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m3EN6O2F002665; Tue, 15 Apr 2008 02:06:24 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: stevefranks@ieee.org References: <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com> Date: Tue, 15 Apr 2008 02:06:24 +0300 In-Reply-To: <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com> (Steve Franks's message of "Mon, 14 Apr 2008 15:43:24 -0700") Message-ID: <877if0qbnz.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: m3EN6VO7022810 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.902, 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:06:54 -0000 On Mon, 14 Apr 2008 15:43:24 -0700, "Steve Franks" wrote: > I'm getting an undefined reference to strndup, so clearly there's a > header somewhere with it - doesn't seem to be in my default libc, > however on 7.0-amd64? I don't see an strndup() function in our libc. keramida@kobe:/usr/src/lib/libc/string$ grep ^strdup *.c strdup.c:strdup(str) keramida@kobe:/usr/src/lib/libc/string$ grep ^strndup *.c keramida@kobe:/usr/src/lib/libc/string$ 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 :)