LWN.net Logo

strncpy

strncpy

Posted Aug 21, 2003 17:29 UTC (Thu) by iabervon (subscriber, #722)
In reply to: strncpy by paulsheer
Parent article: Kernel release status

He did qualify it with "his gcc", which probably has "addl %ebx, %eax" (or whatever that should be; I don't actually know x86 assembly).

I'm not sure why he doesn't have:

src += ((*tmp = *src) != '\0');

though, which is equivalent (since a true relation is defined to evaluate to 1), and doesn't need a clever compiler to skip the branch. Of course, this line would need an explanation for those who haven't read the thread. At least this makes it obvious how many characters are written to the destination string...


(Log in to post comments)

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds