From owner-freebsd-doc@FreeBSD.ORG Thu Jun 23 13:00:28 2005 Return-Path: X-Original-To: freebsd-doc@hub.freebsd.org Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A4EC616A41C for ; Thu, 23 Jun 2005 13:00:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9460B43D48 for ; Thu, 23 Jun 2005 13:00:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j5ND0SjZ076956 for ; Thu, 23 Jun 2005 13:00:28 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j5ND0SZv076955; Thu, 23 Jun 2005 13:00:28 GMT (envelope-from gnats) Date: Thu, 23 Jun 2005 13:00:28 GMT Message-Id: <200506231300.j5ND0SZv076955@freefall.freebsd.org> To: freebsd-doc@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: docs/82508: misleading man page for basename/dirname X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2005 13:00:28 -0000 The following reply was made to PR docs/82508; it has been noted by GNATS. From: Giorgos Keramidas To: Vlad Skvortsov Cc: bug-followup@freebsd.org Subject: Re: docs/82508: misleading man page for basename/dirname Date: Thu, 23 Jun 2005 15:55:52 +0300 On 2005-06-22 02:51, Vlad Skvortsov 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.