Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
From: Chris Faylor <cgf@cygnus.com>
Date: Tue, 10 Oct 2000 14:05:43 -0400
To: "'cygwin@sources.redhat.com'" <cygwin@sources.redhat.com>
Subject: Re: Two snapshot bugs
Message-ID: <20001010140542.D3833@cygnus.com>
Reply-To: cygwin@sources.redhat.com
Mail-Followup-To: "'cygwin@sources.redhat.com'" <cygwin@sources.redhat.com>
References: <779F20BCCE5AD31186A50008C75D99791717B3@silldn_mail1.sanwaint.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.3.6i
In-Reply-To: <779F20BCCE5AD31186A50008C75D99791717B3@silldn_mail1.sanwaint.com>; from EFifer@sanwaint.com on Tue, Oct 10, 2000 at 06:08:53PM +0100

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

