Date: Fri, 1 Jul 2005 06:30:28 GMT From: Vlad Skvortsov <vss@73rus.com> To: freebsd-doc@FreeBSD.org Subject: Re: docs/82508: misleading man page for basename/dirname Message-ID: <200507010630.j616USH6055973@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR docs/82508; it has been noted by GNATS. From: Vlad Skvortsov <vss@73rus.com> To: Giorgos Keramidas <keramida@freebsd.org> Cc: Vlad Skvortsov <vss@high.net.ru>, bug-followup@freebsd.org Subject: Re: docs/82508: misleading man page for basename/dirname Date: Thu, 30 Jun 2005 23:24:25 -0700 Giorgos Keramidas wrote: > On 2005-06-22 02:51, Vlad Skvortsov <vss@high.net.ru> wrote: > >>The man pages for both basename(3) and dirname(3) state that the >>functions return pointers to the internal _static_ storage. However, >>those functions actually perform malloc() call to allocate storage on >>the first invocation. Thus, the memory pointer returned is actually a >>pointer to internal but dynamically allocated storage. >> >>I don't know whether this violates standard or not, but the >>documentation is misleading. > > > The term 'static' here is a warning that these functions are not thread-safe. > > It does NOT mean that the ``bname'' object that is internal to basename() is > actually an array declared as: > > char bname[MAXPATHLEN]; > > It merely means that multiple invocations of the function from concurrent > threads may clobber each other's data, so some form of locking should be used > around calls to basename() from threaded applications or the function should > be avoided altogether. > Yes, I do understand what it supposed to mean. But, anyway, 'static' means 'static', not (not only) 'thread-safe'. ;-) I've ran into this issue while running a testsuite checking for memory leaks. I expected those values to be static, not thread-safe. -- Vlad Skvortsov, vss@73rus.com, vss@high.net.ru
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507010630.j616USH6055973>