Date: Wed, 22 Sep 2010 20:48:03 +0100 From: Rui Paulo <rpaulo@FreeBSD.org> To: Gavin Atkinson <gavin@FreeBSD.org> Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-stable-8@FreeBSD.org Subject: Re: svn commit: r213002 - in stable/8: include lib/libc/gen Message-ID: <4461F6BE-707F-40D4-93F0-6661332A38C6@FreeBSD.org> In-Reply-To: <1285180346.65489.3.camel@buffy.york.ac.uk> References: <201009221800.o8MI0Ze3038214@svn.freebsd.org> <1285180346.65489.3.camel@buffy.york.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 22 Sep 2010, at 19:32, Gavin Atkinson wrote: > On Wed, 2010-09-22 at 18:00 +0000, Rui Paulo wrote: >> Author: rpaulo >> Date: Wed Sep 22 18:00:34 2010 >> New Revision: 213002 >> URL: http://svn.freebsd.org/changeset/base/213002 >>=20 >> Log: >> MFC r197804 (rwatson): >> Add basename_r(3) to complement basename(3). basename_r(3) which = accepts >> a caller-allocated buffer of at least MAXPATHLEN, rather than = using a >> global buffer. >>=20 >> Note about semantics: while this interface is not POSIXy, there's >> another major platform that uses it (Android) and the semantics = between >> the two platforms are pretty much the same. >=20 > Are you sure? >=20 > Ours (just introduced): >=20 > char * basename_r(path, bname) >=20 > Android (from [1]): >=20 > int basename_r(const char* path, char* buffer, size_t bufflen) >=20 > The semantics seem very different. Ours allocates a buffer, on = Android > you pass in a buffer, for a start. Hmm, I only looked at the function body... It seems that the best way to = overcome this is to just add a len parameter. The return value can also = be changed. P.S.: Our basename_r() performs no allocation. You were probably looking = at basename(). Regards, -- Rui Paulo
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4461F6BE-707F-40D4-93F0-6661332A38C6>