- On 2004.07.27, in 4105FE76.1000508@lxnt.info,
- "Alexander Sabourenkov" screwdriver@lxnt.info wrote:
HISTORY A bzero() function appeared in 4.3BSD. Its prototype existed previously in
before it was moved to for IEEE Std 1003.1-2001 (``POSIX.1'') compliance.
bzero(), bcopy(), and bcmp() date from early days of C/Unix standardization, when everyone had one. These were the BSD byte range operations, and memset(), memcpy(), and memcmp() were the non-BSD ones. bzero() maps precisely to memset(), and bcmp() to memcmp(), provided you swap appropriate arguments. These days, since mem*() are in the standard library and b*() are not, it's generally wiser/more portable to use them. bcopy() is slightly different from memcpy(), but if you have no need of this difference, it's likewise better to use memcpy(). b*() are not necessarily supported on a given platform; mem*() are.
The difference between bcopy() and memcpy() is narrow, and occurs only when the destination address plus the range is greater than the source address -- i.e., the copy operation will overlap its own source. In this case, bcopy() is guaranteed to use at least two copy operations, thus preserving the original data. Memcpy() can use only one copy operation, overwriting the original data. (Or: bcopy() is focussed on accuracy, and memcpy() may be optimized for execution speed.) This distinction tends to bring the other b*() and mem*() operations with it, as they're all parts of families.
That's why you'll find it deprecated by some, and praised by others.
-- -D. dgc@uchicago.edu NSIT::ENSS