On 22 Feb 2003, Mij wrote:
>andreas used linux' get_current_dir_name(). Fix with
>this patch
><   cout << get_current_dir_name() << endl;
>>   cout << getcwd(NULL, MAXPATHLEN) << endl;

To follow up on this, and why I provided you with a new patch, from
getcwd's man page:

     char *getcwd(char *buf, size_t size);

On OpenBSD and FreeBSD, it says this:

     If buf is NULL, space is allocated as necessary to store the 
     pathname. This space may later be free(3)'d.

On Solaris:

     If buf is a null pointer, getcwd() will obtain size bytes of
     space using malloc(3C). In this case, the pointer returned by
     getcwd() may be used as the argument in a subsequent call to
     free().

On Linux, it says this:

     If buf is NULL, the behaviour of getcwd() is undefined.

Perhaps the best way is to use NULL in the first argument for the BSD
family, and get_current_working_dir in Linux. Setting the buffer size hard
to 4k is a workaround solution, but it's one that works for all for now.

Andy

-- 
Andreas Aardal Hanssen | http://www.andreas.hanssen.name/gpg
Author of Binc IMAP    | Nil desperandum


Reply via email to