svn commit: r213002 - in stable/8: include lib/libc/gen

Rui Paulo rpaulo at FreeBSD.org
Wed Sep 22 19:48:08 UTC 2010


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
>> 
>> 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.
>> 
>>  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.
> 
> Are you sure?
> 
> Ours (just introduced):
> 
>    char * basename_r(path, bname)
> 
> Android (from [1]):
> 
>    int    basename_r(const char* path, char*  buffer, size_t  bufflen)
> 
> 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




More information about the svn-src-all mailing list