Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Apr 2008 02:06:24 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        stevefranks@ieee.org
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: [?OT?] strndup exists in FreeBSD?
Message-ID:  <877if0qbnz.fsf@kobe.laptop>
In-Reply-To: <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com> (Steve Franks's message of "Mon, 14 Apr 2008 15:43:24 -0700")
References:  <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 14 Apr 2008 15:43:24 -0700, "Steve Franks" <stevefranks@ieee.org> 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 :)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?877if0qbnz.fsf>