127 lines
2.8 KiB
Plaintext
127 lines
2.8 KiB
Plaintext
'\"macro stdmacro
|
|
.if n .pH g3c.memory @(#)memory 40.16 of 5/22/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} memory 3C "C Development Set" "\&"
|
|
.if \nX=1 .ds x} memory 3C "C Development Set"
|
|
.if \nX=2 .ds x} memory 3C "" "\&"
|
|
.if \nX=3 .ds x} memory "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4memory\f1: \f4memccpy\f1, \f4memchr\f1, \f4memcmp\f1, \f4memcpy\f1, \f4memmove\f1, \f4memset\f1 \- memory operations
|
|
.SH SYNOPSIS
|
|
\f4#include <string.h>\f1
|
|
.PP
|
|
\f4void *memccpy (void \(**s1, const void \(**s2, int c, size_t n);\f1
|
|
.PP
|
|
\f4void *memchr (const void \(**s, int c, size_t n);\f1
|
|
.PP
|
|
\f4int memcmp (const void \(**s1, const void \(**s2, size_t n);\f1
|
|
.PP
|
|
\f4void *memcpy (void \(**s1, const void \(**s2, size_t n);\f1
|
|
.PP
|
|
\f4void *memmove (void \(**s1, const void \(**s2, size_t n);\f1
|
|
.PP
|
|
\f4void *memset (void \(**s, int c, size_t n);\f1
|
|
.SH DESCRIPTION
|
|
These 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.
|
|
.PP
|
|
\f4memccpy\fP
|
|
copies bytes from memory area
|
|
.I s2\^
|
|
into
|
|
.IR s1 ,
|
|
stopping after the first occurrence of
|
|
.I c\^
|
|
(converted to an \f4unsigned char\fP)
|
|
has been copied, or after
|
|
.I n\^
|
|
bytes have been copied, whichever comes first.
|
|
It returns a pointer to the byte after
|
|
the copy of
|
|
.I c\^
|
|
in
|
|
.IR s1 ,
|
|
or a
|
|
null pointer if
|
|
.I c\^
|
|
was not found in the first
|
|
.I n\^
|
|
bytes of
|
|
.IR s2 .
|
|
.PP
|
|
\f4memchr\fP
|
|
returns a pointer to the first
|
|
occurrence of
|
|
.I c\^
|
|
(converted to an \f4unsigned char\fP)
|
|
in the first
|
|
.I n\^
|
|
bytes
|
|
(each interpreted as an \f4unsigned char\fP)
|
|
of memory area
|
|
.IR s ,
|
|
or a
|
|
null pointer if
|
|
.I c\^
|
|
does not occur.
|
|
.PP
|
|
\f4memcmp\fP
|
|
compares its arguments, looking at the first
|
|
.I n\^
|
|
bytes
|
|
(each interpreted as an \f4unsigned char\fP),
|
|
and returns an integer
|
|
less than, equal to, or greater than 0,
|
|
according as
|
|
.I s1\^
|
|
is lexicographically less than, equal to, or
|
|
greater than
|
|
.I s2\^
|
|
when taken to be unsigned characters.
|
|
.PP
|
|
\f4memcpy\fP
|
|
copies
|
|
.I n\^
|
|
bytes from memory area
|
|
.I s2\^
|
|
to
|
|
.IR s1 .
|
|
It returns
|
|
.IR s1 .
|
|
.PP
|
|
\f4memmove\f1 copies \f2n\f1 bytes from memory areas \f2s2\f1 to \f2s1\f1.
|
|
Copying between objects that overlap will take place correctly.
|
|
It returns \f2s1\f1.
|
|
.PP
|
|
\f4memset\fP
|
|
sets the first
|
|
.I n\^
|
|
bytes in memory area
|
|
.I s\^
|
|
to the value of
|
|
.IR c
|
|
(converted to an \f4unsigned char\fP).
|
|
It returns
|
|
.IR s .
|
|
.SH "SEE ALSO"
|
|
\f4string\f1(3C).
|
|
.SH "CAVEATS"
|
|
For maximum portability,
|
|
.I memmove\^
|
|
should be used when the memory areas indicated by
|
|
.B s1\^
|
|
and
|
|
.B s2\^
|
|
may overlap, and
|
|
.I memcpy\^
|
|
used for faster copying between non-overlapping areas. In this implementation,
|
|
however,
|
|
.I memcpy\^
|
|
is an efficient copying algorithm which correctly handles overlapping areas.
|
|
.\" @(#)memory.3c 6.2 of 10/20/83
|
|
.Ee
|