Penguin

Differences between current version and previous revision of strncpy(3).

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 6 Last edited on Tuesday, May 24, 2005 6:48:42 pm by HarunVos
Older page: version 5 Last edited on Monday, October 28, 2002 8:11:34 pm by PerryLorier Revert
@@ -1,5 +1,4 @@
-  
 !!!STRCPY 
 ---- 
 !!NAME 
  
@@ -46,8 +45,8 @@
 !!CONFORMING TO 
 SVID 3, POSIX, BSD 4.3, ISO 9899 
  
 !!HISTORY 
-Rumour has it that the reason that strcpy () has such bizarre semantics (copying up to the entire length of the string and not leaving space for the terminating '', and padding to the end of the buffer with ''s if it's shorter) come from the days when you could read/write a directory. If you wanted to create a hardlink you opened the directory for writing and wrote the filename and the inode number into the directory. The filename had to be exactly ''n'' bytes long and must be '' padded (instead of just terminated), hence the strncpy() semantics. It's far too late now to change the semantics to something more sane, so the [OpenBSD] people are advocating the use of strlcpy(3) instead. Note, in high performance applications, strlcpy(3) is much faster than strncpy(3) as it doesn't waste time padding the entire string. 
+Rumour has it that the reason that strncpy () has such bizarre semantics (copying up to the entire length of the string and not leaving space for the terminating '', and padding to the end of the buffer with ''s if it's shorter) come from the days when you could read/write a directory. If you wanted to create a hardlink you opened the directory for writing and wrote the filename and the inode number into the directory. The filename had to be exactly ''n'' bytes long and must be '' padded (instead of just terminated), hence the strncpy() semantics. It's far too late now to change the semantics to something more sane, so the [OpenBSD] people are advocating the use of strlcpy(3) instead. Note, in high performance applications, strlcpy(3) is much faster than strncpy(3) as it doesn't waste time padding the entire string. 
  
 !!SEE ALSO 
 bcopy(3), memccpy(3), memcpy(3), memmove(3) 
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.