Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Friday, August 13, 2021
 
 

bstring(3C)

Name

bstring, bcopy, bcmp, bzero, explicit_bzero - memory operations

Synopsis

#include <strings.h>

void bcopy(const void *
s1, void *s2, 
size_t n);
int bcmp(const void *
s1, const void *
s2, size_t n);
void bzero(void *
s, size_t 
n);
void explicit_bzero(void *
s, size_t 
n);

Description

The bcopy(), bcmp(), bzero(), and explicit_bzero() functions operate as efficiently as possible on memory areas (arrays of bytes bounded by a count, not terminated by a null character). They do not check for the overflow of any receiving memory area. These functions are similar to the memcpy(), memcmp(), memset(), and explicit_memset() functions described on the memory(3C) manual page.

The bcopy() function copies n bytes from memory area s1 to s2. Copying between objects that overlap will take place correctly.

The bcmp() function compares the first n bytes of its arguments, returning 0 if they are identical and 1 otherwise. The bcmp() function always returns 0 when n is 0.

The bzero() function sets the first n bytes in memory area s to 0.

The explicit_bzero() function performs the same operation as bzero(). It differs from bzero() in that it will not be removed by compiler dead store analysis. The explicit_bzero() function is useful for clearing no longer needed sensitive data to ensure that it does not remain accessible in process memory.

Warnings

The bcopy() function takes parameters backwards from memcpy(). See memory(3C).

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe
Standard

See Also

timingsafe_bcmp(3C), memory(3C), attributes(7), standards(7)