[Mplayer-dev-eng] Re: [Mplayer-cvslog] CVS: main/Gui/mplayer/gtk fs.h,1.2,1.Tue Sep 4 00:36:29 2001

Juergen Keil jk at tools.de
Tue Sep 4 11:50:52 CEST 2001


> > Hello, wouldn't it be better to use glib function g_get_current_dir
> > instead? It's more portable this way. Besides, under FreeBSD (don't know
> > about other BSDs) we also need getcwd(NULL, PATH_MAX) instead of
> > get_current_dir_name()
>
> IMHO we always should use the getcwd() functions, because it's POSIX standard.
> I've never heard about *get_current_dir versions, it's maybe
> linux/glibc-specific.

Yes, get_current_dir_name() seems to be glibc specific.  Linux's unistd.h 
contains:

#ifdef  __USE_GNU
/* Return a malloc'd string containing the current directory name.
   If the environment variable `PWD' is set, and its value is correct,
   that value is used.  */
extern char *get_current_dir_name (void) __THROW;
#endif


And the manual page contains:

...
      get_current_dir_name,   which   is   only   prototyped  if
      _GNU_SOURCE is defined, will malloc(3) an array big enough
      to  hold  the  current directory name.  If the environment
      variable PWD is set, and its value is correct,  then  that
      value will be returned.
...



With the execption of the $PWD optimization, getcwd() and
get_current_dir_name() seem to be identical.  Since the fileselector
code seems to navigate through the filesystem using chdir() and
$PWD is not updated, the $PWD optimization for get_current_dir_name()
is useless.


On the other hand, most uses of get_current_dir_name() is for the 
second parameter ("directory") of the CheckDir() function,  and that
parameter is not used in CheckDir, anyway.

(So, the only use of the current directoy passed to CheckDir is to
leak some memory  :-)


--
Jürgen Keil          		jk at tools.de
Tools GmbH			+49 (228) 9858011


_______________________________________________
Mplayer-dev-eng mailing list
Mplayer-dev-eng at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mplayer-dev-eng



More information about the MPlayer-dev-eng mailing list