This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Two snapshot bugs


On Tue, Oct 10, 2000 at 06:08:53PM +0100, Fifer, Eric wrote:
>+ getcwd() seems to be busted:
>
>	#include <stdio.h>
>	main() { printf("getcwd=%s\n", getcwd(NULL, 0)); }
>
>  produces:
>
>	getcwd=(null)

In any description of getcwd that I"ve found, specifying '0' as the size
means that you allocate a zero length buffer.

The linux man page says this:

       As  an  extension  to the POSIX.1 standard, getcwd() allo-
       cates the buffer dynamically using malloc() if buf is NULL
       on  call.   In  this  case,  the  allocated buffer has the
       length size unless size is less than  zero,  when  buf  is
       allocated  as  big  as  necessary.   It  is possible (and,
       indeed, advisable) to free() the buffers if they have been
       obtained this way.

So 'getcwd (NULL, -1)' should return something but 'getcwd (NULL, 0)', IMO,
should not.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]