126 lines · 2.1 KB · Text
RawDownload
.TH MEMORY 2.SH NAMEmemccpy, memchr, memcmp, memcpy, memmove, memset \- memory operations.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.ta \w'\fLvoid* 'u.Bvoid*	memccpy(void *s1, void *s2, int c, ulong n).PP.Bvoid*	memchr(void *s, int c, ulong n).PP.Bint	memcmp(void *s1, void *s2, ulong n).PP.Bvoid*	memcpy(void *s1, void *s2, ulong n).PP.Bvoid*	memmove(void *s1, void *s2, ulong n).PP.Bvoid*	memset(void *s, int c, ulong 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 Memcpycopies.I nbytes from memory area .I s2to.IR s1 .It returns.IR s1 ..PP.I Memmoveworks like.IR memcpy ,except that it is guaranteed to work if.I s1and.IR s2overlap..PP.I Memsetsets the first.I nbytes in memory area.I sto the value of byte.IR c .It returns.IR s ..SH SOURCEAll these routines have portable C implementations in.BR /sys/src/libc/port .Most also have machine-dependent assembly language implementations in.BR /sys/src/libc/$objtype ..SH SEE ALSO.IR strcat (2).SH BUGSANSI C does not require.I memcpyto handle overlapping source and destination; on Plan 9, it does, so.I memmoveand.I memcpybehave identically..PPIf.I memcpyand.I memmoveare handed a negative count, they abort.