[haiku-bugs] Re: [Haiku] #8481: strncpy doesn't pad the destination string with NULs

  • From: "pdziepak" <trac@xxxxxxxxxxxx>
  • Date: Wed, 25 Apr 2012 17:12:21 -0000

#8481: strncpy doesn't pad the destination string with NULs
   Reporter:  hamish             |      Owner:  tqh
       Type:  bug                |     Status:  in-progress
   Priority:  normal             |  Milestone:  R1
  Component:  System/libroot.so  |    Version:  R1/Development
 Resolution:                     |   Keywords:  strncpy
 Blocked By:                     |   Blocking:
Has a Patch:  1                  |   Platform:  All

Comment (by pdziepak):

 Replying to [comment:12 tqh]:
 > Yes, mine too. I was fishing for comments on if we should have special
 case for x86. Probably not worth it.

 Functions like `strncpy`, `strncmp`, `strcpy`, `memcpy`, `memcmp`, etc are
 usually implemented in assembly (thus there are different versions of them
 for each architecture). Apparently it is still worth to do that. I wrote a
 [http://pastebin.com/5iQ8LxUD simple test] and compiled it on gcc 4.6.3.
 `memcpy1` takes about 300ms to complete, while `memcpy2` needs only 100ms.
 Obviously, `memcpy` is the easiest of these functions to make run much
 faster when implemented in assembly, but then again it may be worth to
 consider such option.

Ticket URL: <http://dev.haiku-os.org/ticket/8481#comment:15>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: