On Fri, Feb 18, 2005 at 06:42:12PM -0800, Barry deFreese wrote:
@@ -327,12 +328,18 @@ Util_BuildList(char *word[])
static void
Util_Autoload()
{
- char oldcwd[PATH_MAX];
+ #ifdef HAVE_GET_CURRENT_DIR_NAME
+ char *oldcwd = get_current_dir_name ();
+ #else
+ char oldcwd[PATH_MAX];
+ #endif
const char *dir_name;
struct dirent *ent;
DIR *dir;
- if (getcwd(oldcwd, PATH_MAX) == NULL)
+ #ifndef HAVE_GET_CURRENT_DIR_NAME
+ if (getcwd(oldcwd, PATH_MAX) == NULL)
return;
+ #endif
/* we need local filesystem encoding for chdir, opendir etc */
dir_name = xchat_get_info(ph, "xchatdirfs");
/* fallback for pre-2.0.9 xchat */
@@ -350,6 +357,9 @@ Util_Autoload()
}
closedir(dir);
chdir(oldcwd);
+ #ifdef HAVE_GET_CURRENT_DIR_NAME
+ free(oldcwd);
+ #endif
}
What happens if get_current_dir_name returns NULL?