This is the mail archive of the cygwin-patches 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]
Other format: [Raw text]

Re: avoid calling strlen() twice in readlink()


On 03/08/2012 06:37 AM, Václav Zeman wrote:
> Hi.
> 
> Here is a tiny patch to avoid calling strlen() twice in readlink().
> 

>  
> -  ssize_t len = min (buflen, strlen (pathbuf.get_win32 ()));
> +  size_t pathbuf_len = strlen (pathbuf.get_win32 ());
> +  size_t len = MIN (buflen, pathbuf_len);
>    memcpy (buf, pathbuf.get_win32 (), len);

For that matter, is calling pathbuf.get_win32() twice worth factoring out?

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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