X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Fri, 18 Dec 2009 11:10:32 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: cygwin_conv_path() documentation RFE
Message-ID: <20091218101032.GH8059@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <4B2AE912.7090003@etr-usa.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4B2AE912.7090003@etr-usa.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Dec 17 19:29, Warren Young wrote:
> On this page
> 
> 	http://cygwin.com/1.7/cygwin-api/func-cygwin-conv-path.html
> 
> the size parameter should say whether it's measured in bytes or
> characters.
> 
> For instance, if I pass CCP_POSIX_TO_WIN_W for the first parameter
> and a pure ASCII file name for the 'from' parameter, it's obvious
> the 'to' buffer needs to be at least 2x the size of 'from'.  The
> question the docs don't answer is whether I should pass >=
> 2*(strlen(from)+1) for size or >= strlen(from)+1?

I really thought that would be clear from the description of what
happens if size is 0:

  "If size is 0, cygwin_conv_path just returns the required buffer size
   in bytes."

and the subsequent example code which uses the size returned by
cygwin_conv_path in a call to malloc and then, unchanged in the next
cygwin_conv_path call.  I suggest to implement it as in the example.
Otherwise you will potentially need a buffer of 64K to return the
path in it.  Alternatively just use the cygwin_create_path function
which will malloc the buffer for you.

I'll change the description so that the value of "size" should be clear
from the beginning.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

