Date: Tue, 15 Apr 2008 02:50:14 +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: <87y77gov2h.fsf@kobe.laptop> In-Reply-To: <539c60b90804141627r502ec7eeudd5b3112cd891ed@mail.gmail.com> (Steve Franks's message of "Mon, 14 Apr 2008 16:27:42 -0700") References: <539c60b90804141543h29b3c2f4y8c38694821d67d95@mail.gmail.com> <877if0qbnz.fsf@kobe.laptop> <539c60b90804141627r502ec7eeudd5b3112cd891ed@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 14 Apr 2008 16:27:42 -0700, "Steve Franks" <stevefranks@ieee.org> 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 :(
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87y77gov2h.fsf>