2 .\" Copyright (c) 2014, Joyent, Inc.
3 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
4 .\" Copyright 1989 AT&T
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH MEMORY 3C "Feb 4, 2009"
10 memory, memccpy, memchr, memcmp, memcpy, memmem, memmove, memset \- memory operations
16 \fBvoid *\fR\fBmemccpy\fR(\fBvoid *restrict\fR \fIs1\fR, \fBconst void *restrict\fR \fIs2\fR,
17 \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
22 \fBvoid *\fR\fBmemchr\fR(\fBconst void *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
27 \fBint\fR \fBmemcmp\fR(\fBconst void *\fR\fIs1\fR, \fBconst void *\fR\fIs2\fR, \fBsize_t\fR \fIn\fR);
32 \fBvoid *\fR\fBmemcpy\fR(\fBvoid *restrict\fR \fIs1\fR, \fBconst void *restrict\fR \fIs2\fR, \fBsize_t\fR \fIn\fR);
37 \fBvoid *\fR\fBmemmem\fR(\fBconst void *\fR\fIl\fR, \fBsize_t\fR \fIl_len\fR, \fBconst void *\fR\fIs\fR, \fBsize_t\fR \fIs_len\fR);
42 \fBvoid *\fR\fBmemmove\fR(\fBvoid *\fR\fIs1\fR, \fBconst void *\fR\fIs2\fR, \fBsize_t\fR \fIn\fR);
47 \fBvoid *\fR\fBmemset\fR(\fBvoid *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
55 \fBconst void *\fR\fBmemchr\fR(\fBconst void *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
62 \fBvoid *std::\fR\fBmemchr\fR(\fBvoid *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
67 These functions operate as efficiently as possible on memory areas (arrays of
68 bytes bounded by a count, not terminated by a null character). They do not
69 check for the overflow of any receiving memory area.
72 The \fBmemccpy()\fR function copies bytes from memory area \fIs2\fR into
73 \fIs1\fR, stopping after the first occurrence of \fIc\fR (converted to an
74 \fBunsigned char\fR) has been copied, or after \fIn\fR bytes have been copied,
75 whichever comes first. It returns a pointer to the byte after the copy of
76 \fIc\fR in \fIs1\fR, or a null pointer if \fIc\fR was not found in the first
77 \fIn\fR bytes of \fIs2\fR.
80 The \fBmemchr()\fR function returns a pointer to the first occurrence of
81 \fIc\fR (converted to an \fBunsigned char\fR) in the first \fIn\fR bytes (each
82 interpreted as an \fBunsigned char\fR) of memory area \fIs\fR, or a null
83 pointer if \fIc\fR does not occur.
86 The \fBmemcmp()\fR function compares its arguments, looking at the first
87 \fIn\fR bytes (each interpreted as an \fBunsigned char\fR), and returns an
88 integer less than, equal to, or greater than 0, according as \fIs1\fR is
89 lexicographically less than, equal to, or greater than \fIs2\fR when taken to
90 be unsigned characters.
93 The \fBmemcpy()\fR function copies \fIn\fR bytes from memory area \fIs2\fR to
94 \fIs1\fR. It returns \fIs1\fR. If copying takes place between objects that
95 overlap, the behavior is undefined.
98 The \fBmemmem()\fR function searches for the \fIs_len\fR long byte pattern
99 \fIs\fR in the memory region starting at \fBl\fR for \fl_len\fR bytes. If a
100 match is found, a pointer to the starting location in \fIl\fR is returned. If no
101 match is found, \fIl_len\fR is zero, \fIs_len\fR is zero, or \fIl_len\fR is less
102 than \fIs_len\fR, then a null pointer is return.
105 The \fBmemmove()\fR function copies \fIn\fR bytes from memory area \fIs2\fR to
106 memory area \fIs1\fR. Copying between objects that overlap will take place
107 correctly. It returns \fIs1\fR.
110 The \fBmemset()\fR function sets the first \fIn\fR bytes in memory area \fIs\fR
111 to the value of \fIc\fR (converted to an \fBunsigned char\fR). It returns
115 Using \fBmemcpy()\fR might be faster than using \fBmemmove()\fR if the
116 application knows that the objects being copied do not overlap.
119 See \fBattributes\fR(5) for descriptions of the following attributes:
127 ATTRIBUTE TYPE ATTRIBUTE VALUE
129 Interface Stability Stable
133 Standard See \fBstandards\fR(5).
138 \fBstring\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
141 Overlap between objects being copied can arise even when their (virtual)
142 address ranges appear to be disjoint; for example, as a result of
143 memory-mapping overlapping portions of the same underlying file, or of
144 attaching the same shared memory segment more than once.