.TH MEMORY 10.2.SH NAMEmemccpy, memchr, memcmp, memcpy, memmove, memset \- memory operations.SH SYNOPSIS.ta \w'\fLvoid* 'u.Bvoid* memccpy(void *s1, void *s2, int c, long n).PP.Bvoid* memchr(void *s, int c, long n).PP.Bint memcmp(void *s1, void *s2, long n).PP.Bvoid* memcpy(void *s1, void *s2, long n).PP.Bvoid* memmove(void *s1, void *s2, long n).PP.Bvoid* memset(void *s, int c, long n).SH DESCRIPTIONThese functions operate efficiently on memory areas(arrays of bytes bounded by a count, not terminated by a zero byte).They do not check for the overflow of any receiving memory area..PP.I Memccpycopies bytes from memory area.I s2into.IR s1 ,stopping after the first occurrence of byte.I chas been copied, or after.I nbytes have been copied, whichever comes first.It returns a pointer to the byte afterthe copy of.I cin.IR s1 ,or zero if.I cwas not found in the first.I nbytes of.IR s2 ..PP.I Memchrreturns a pointer to the firstoccurrence of byte.I cin the first.I nbytes of memory area.IR s,or zero if.I cdoes not occur..PP.I Memcmpcompares its arguments, looking at the first.I nbytes only, and returns an integerless than, equal to, or greater than 0,according as.I s1is lexicographically less than, equal to, orgreater than.IR s2 .The comparison is bytewise unsigned..PP.I Memmovecopies.I nbytes from memory area .I s2to.IR s1 .It returns.IR s1 .It is guaranteed to work if.I s1and.IR s2overlap..PPIn the Inferno kernel.I memcpyis equivalent to.IR memmove .(In ANSI C, by contrast,.I memcpydoes not account for overlapping memory regions.).PP.I Memsetsets the first.I nbytes in memory area.I sto the value of the least significant byte of.IR c .It returns.IR s ..SH DIAGNOSTICSIf.I memcpyand.I memmoveare handed negative counts, they abort..SH SOURCE.BR /libkern/mem*.c.br.BR /libkern/mem*-\fIobjtype\fP.s.SH SEE ALSO.IR strcat (10.2)
.TH MEMORY 10.2
.SH NAME
memccpy, memchr, memcmp, memcpy, memmove, memset \- memory operations
.SH SYNOPSIS
.ta \w'\fLvoid* 'u
.B
void* memccpy(void *s1, void *s2, int c, long n)
.PP
.B
void* memchr(void *s, int c, long n)
.PP
.B
int memcmp(void *s1, void *s2, long n)
.PP
.B
void* memcpy(void *s1, void *s2, long n)
.PP
.B
void* memmove(void *s1, void *s2, long n)
.PP
.B
void* memset(void *s, int c, long n)
.SH DESCRIPTION
These functions operate efficiently on memory areas
(arrays of bytes bounded by a count, not terminated by a zero byte).
They do not check for the overflow of any receiving memory area.
.PP
.I Memccpy
copies bytes from memory area
.I s2
into
.IR s1 ,
stopping after the first occurrence of byte
.I c
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 zero if
.I c
was not found in the first
.I n
bytes of
.IR s2 .
.PP
.I Memchr
returns a pointer to the first
occurrence of byte
.I c
in the first
.I n
bytes of memory area
.IR s,
or zero if
.I c
does not occur.
.PP
.I Memcmp
compares its arguments, looking at the first
.I n
bytes only, 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
.IR s2 .
The comparison is bytewise unsigned.
.PP
.I Memmove
copies
.I n
bytes from memory area
.I s2
to
.IR s1 .
It returns
.IR s1 .
It is guaranteed to work if
.I s1
and
.IR s2
overlap.
.PP
In the Inferno kernel
.I memcpy
is equivalent to
.IR memmove .
(In ANSI C, by contrast,
.I memcpy
does not account for overlapping memory regions.)
.PP
.I Memset
sets the first
.I n
bytes in memory area
.I s
to the value of the least significant byte of
.IR c .
It returns
.IR s .
.SH DIAGNOSTICS
If
.I memcpy
and
.I memmove
are handed negative counts, they abort.
.SH SOURCE
.BR /libkern/mem*.c
.br
.BR /libkern/mem*-\fIobjtype\fP.s
.SH SEE ALSO
.IR strcat (10.2)