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

Alban Bedel albeu at free.fr
Wed Apr 30 10:15:24 CEST 2003


Hi Robert Millan,

on Wed, 30 Apr 2003 00:29:08 +0200 you wrote:

> 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.

How care of optimizing such stuff. Imho there enouth #ifdef everywhere in
mplayer. In this case there is a solution wich work for everyone, we don't
need to bloat the code with such things. Use only dynamic allocation.
	Albeu



More information about the MPlayer-dev-eng mailing list