man pages are rarely up-to-date. Actually, linux' getcwd
behaves exactly the same every other unices do. buf = NULL means
"malloc the string yourself".

using NULL is better and more elegant way to implement the thing.

Il sab, 2003-02-22 alle 13:39, Andreas Aardal Hanssen ha scritto:
> 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
> 
> 
> 
-- 
Mij     -o-     [EMAIL PROTECTED]       -o-     http://mij.oltrelinux.com

Reply via email to