bzero VS memset

bzero:

The bzero is not in standard (ANSI) C function, it appeared in 4.3BSD (Berkeley UNIX C library). Its prototype existed previously in <string.h> before it was moved to <strings.h> for IEEE Std 1003.1-2001 (``POSIX.1'') compliance.

To use it in ANSI C you have to define it first(Some system do this work). memset, on the other hand, pre-exists and has a known meaning.
This function is deprecated (marked as LEGACY in POSIX.1-2001): use
memset in new programs.

This is a partially obsolete alternative for memset, derived from BSD. Note that it is not as general as memset, because the only value it can store is zero.

Reference:
http://www.opengroup.org/onlinepubs/000095399/functions/bzero.html

 

http://people.redhat.com/drepper/posix-option-groups.html

memset:

function conforms to ISO/IEC 9899:1990 (``ISO C90'').It was adopted by the System V, ANSI C and POSIX standards and bzero deprecated.

Reference:http://www.opengroup.org/onlinepubs/000095399/functions/memset.html


When porting to Solaris, here is possible ANSI/POSIX/SVR4 replacements for popular BSD functions:

Reference:http://ns.uoregon.edu/portability-faq/soltopic4.html

Comments:

Post a Comment:
Comments are closed for this entry.
About

williamxue

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today