Files
seta75D ff309bfe1c Init
2021-10-11 18:37:13 -03:00

156 lines
2.9 KiB
Groff

.\" @(#)memory.3 1.1 94/10/31 SMI; from S5
.TH MEMORY 3 "6 October 1987"
.SH NAME
memory, memccpy, memchr, memcmp, memcpy, memset \- memory operations
.SH SYNOPSIS
.LP
.nf
.ft B
.B #include <memory.h>
.ft
.fi
.LP
.nf
.ft B
char *memccpy(s1, s2, c, n)
char *s1, *s2;
int c, n;
.ft
.fi
.LP
.nf
.ft B
char *memchr(s, c, n)
char *s;
int c, n;
.ft
.fi
.LP
.nf
.ft B
int memcmp(s1, s2, n)
char *s1, *s2;
int n;
.ft
.fi
.LP
.nf
.ft B
char *memcpy(s1, s2, n)
char *s1, *s2;
int n;
.ft
.fi
.LP
.nf
.ft B
char *memset(s, c, n)
char *s;
int c, n;
.ft
.fi
.SH DESCRIPTION
.IX "memccpy function" "" "\fLmemccpy()\fR \(em copy memory character strings"
.IX "copy" "memory character strings \(em \fLmemccpy()\fR"
.IX "memchr()" "" "\fLmemchr()\fR \(em index memory characters"
.IX "index memory characters memchr()" "" "index memory characters \(em \fLmemchr()\fR"
.IX "memcmp()" "" "\fLmemcmp()\fR compare memory characters"
.IX "compare" "memory characters \(em \fLmemcmp()\fR"
.IX "memcpy()" "" "\fLmemcpy()\fR copy memory character fields"
.IX "copy" "memory character fields \(em \fLmemcpy()\fR"
.IX "memset()" "" "\fLmemset()\fR assign to memory characters"
.IX "assign to memory characters memset" "" "assign to memory characters \(em \fLmemset()\fR"
.IX "memory operations"
.LP
These functions operate as efficiently as
possible on memory areas (arrays of characters
bounded by a count, not terminated by a
null
character). They do not check for the overflow
of any receiving memory area.
.LP
.B memccpy(\|)
copies characters from memory area
.I s2
into
.IR s1 ,
stopping after the first occurrence of character
.I c
has been copied, or after
.I n
characters have been copied, whichever comes first.
It returns a pointer to the character after
the copy of
.I c
in
.IR s1 ,
or a
.SM NULL
pointer if
.I c
was not found in the first
.I n
characters of
.IR s2 .
.LP
.B memchr(\|)
returns a pointer to the first
occurrence of character
.I c
in the first
.I n
characters of memory area
.IR s ,
or a
.SM NULL
pointer if
.I c
does not occur.
.LP
.B memcmp(\|)
compares its arguments, looking at the first
.I n
characters 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 .
.LP
.B memcpy(\|)
copies
.I n
characters from memory area
.I s2
to
.IR s1 .
It returns
.IR s1 .
.LP
.B memset(\|)
sets the first
.I n
characters in memory area
.I s
to the value of character
.IR c .
It returns
.IR s .
.SH NOTES
For user convenience, all these functions are declared in the
.B <memory.h>
header file.
.SH BUGS
.B memcmp(\|)
uses native character comparison, which
is signed on some machines
and unsigned on other machines.
Thus the sign of the value returned when one of the
characters has its high-order bit set is
implementation-dependent.
.LP
Character movement is performed differently
in different implementations.
Thus overlapping moves may yield surprises.