[MPlayer-dev-eng] [PATCH] fix for unconditional use of PATH_MAX

Robert Millan zeratul2 at wanadoo.es
Wed Apr 30 00:29:08 CEST 2003


On Tue, Apr 29, 2003 at 11:25:09PM +0200, Fabien Tassin wrote:
> 
> this is defined in POSIX.1.
> I just reread POSIX.4 and it says that pathconf()/fpathconf() must be
> used to collect the information (here, using _PC_PATH_MAX).
> If it returns -1 but does not set errno, then there is no limit
> for the symbol. Else, PATH_MAX value is returned.
> I agree that the default value should not be used directly but queried
> instead.

sure, if you want to be portable for systems that don't have PATH_MAX
but do have specific limits depending on the path you specify
(i never heard any of these, though).

but keep in mind to have a fallback for dynamic allocation. the
system might not define PATH_MAX and never return a value with pathconf
other than -1 (this is the case for GNU).

a realy portable code would look like this:

#ifdef PATH_MAX
  path_max = PATH_MAX;
#else
  path_max = pathconf("foo", _PC_PATHMAX);
#endif
  if (path_max == -1)
     use dynamic allocation;
  else
     use static allocation;

of course, if you don't care you can just use dynamic allocation for
all. then it'd work ok everyplace but wouldn't be as much optimised.

-- 
Robert Millan

make: *** No rule to make target `war'.  Stop.

Another world is possible - Just say no to genocide



More information about the MPlayer-dev-eng mailing list