Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!stc!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.unix.wizards Subject: Re: of course! Message-ID: <1056@root44.co.uk> Date: 29 Nov 89 14:05:22 GMT References: <152@norsat.UUCP> <2586@unisoft.UUCP> <15769@bloom-beacon.MIT.EDU> <17264@rpp386.cactus.org> <4526@ski.cs.vu.nl> <17303@rpp386.cactus.org> <1051@root44.co.uk> <1989Nov22.224209.28911@athena.mit.edu> Reply-To: gwc@root.co.uk (Geoff Clare) Organization: UniSoft Ltd, London, England Lines: 32 In article <1989Nov22.224209.28911@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <1051@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes: >= Another is that PATH_MAX might not be defined (it should >=always be obtained via pathconf() in portable applications). > > Not convinced this is a major problem. I've yet to run into a Unix >programming environment that doesn't somewhere in a header file give >you some indication of the maximum path length, I don't know of any current systems like this, either, but it's entirely possible there will be systems like this in the near future. That's because POSIX.1 says that PATH_MAX is optional and provides pathconf() to obtain its value at runtime. Even if there is a PATH_MAX in it should not be used to dimension an array which is assumed to be able to hold any path name, because the actual maximum is allowed to be higher. E.g. an NFS mounted file system might allow longer names than local file systems. > I therefore fail to see why malloc is a better choice than an >automatic variable. Given that the length of an array to hold all possible path names is not known until runtime, you have no choice but to use malloc(). So why not just malloc only what you need? Your objections on performance grounds are unfounded. Only the first call to the routine will be slower. After that malloc() will just adjust a few pointers. -- Geoff Clare, UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH gwc@root.co.uk (Dumb mailers: ...!uunet!root.co.uk!gwc) Tel: +44-1-315-6600