]>
Commit | Line | Data |
---|---|---|
1 | .\" Copyright (c) 1991, 1993 | |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 4. Neither the name of the University nor the names of its contributors | |
13 | .\" may be used to endorse or promote products derived from this software | |
14 | .\" without specific prior written permission. | |
15 | .\" | |
16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | .\" SUCH DAMAGE. | |
27 | .\" | |
28 | .\" @(#)memory.3 8.1 (Berkeley) 6/4/93 | |
29 | .\" $FreeBSD: src/lib/libc/stdlib/memory.3,v 1.12 2007/01/09 00:28:10 imp Exp $ | |
30 | .\" | |
31 | .Dd June 4, 1993 | |
32 | .Dt MEMORY 3 | |
33 | .Os | |
34 | .Sh NAME | |
35 | .Nm alloca , | |
36 | .Nm calloc , | |
37 | .Nm free , | |
38 | .Nm malloc , | |
39 | .Nm mmap , | |
40 | .Nm realloc | |
41 | .Nd general memory allocation operations | |
42 | .Sh LIBRARY | |
43 | .Lb libc | |
44 | .Sh SYNOPSIS | |
45 | .In stdlib.h | |
46 | .Ft void * | |
47 | .Fo alloca | |
48 | .Fa "size_t size" | |
49 | .Fc | |
50 | .Ft void * | |
51 | .Fo calloc | |
52 | .Fa "size_t nelem" | |
53 | .Fa "size_t elsize" | |
54 | .Fc | |
55 | .Ft void | |
56 | .Fo free | |
57 | .Fa "void *ptr" | |
58 | .Fc | |
59 | .Ft void * | |
60 | .Fo malloc | |
61 | .Fa "size_t size" | |
62 | .Fc | |
63 | .Ft void * | |
64 | .Fo realloc | |
65 | .Fa "void *ptr" | |
66 | .Fa "size_t size" | |
67 | .Fc | |
68 | .In sys/mman.h | |
69 | .Ft void * | |
70 | .Fo mmap | |
71 | .Fa "void * addr" | |
72 | .Fa "size_t len" | |
73 | .Fa "int prot" | |
74 | .Fa "int flags" | |
75 | .Fa "int fildes" | |
76 | .Fa "off_t off" | |
77 | .Fc | |
78 | .Sh DESCRIPTION | |
79 | These functions allocate and free memory for the calling process. | |
80 | They are described in the | |
81 | individual manual pages. | |
82 | .Sh LEGACY SYNOPSIS | |
83 | .Fd #include <sys/types.h> | |
84 | .Fd #include <sys/mman.h> | |
85 | .Pp | |
86 | .Ft void * | |
87 | .br | |
88 | .Fo mmap | |
89 | .Fa "void * addr" | |
90 | .Fa "size_t len" | |
91 | .Fa "int prot" | |
92 | .Fa "int flags" | |
93 | .Fa "int fildes" | |
94 | .Fa "off_t off" | |
95 | .Fc ; | |
96 | .Pp | |
97 | The include file | |
98 | .In sys/types.h | |
99 | is needed for this function. | |
100 | .Sh COMPATIBILITY | |
101 | .Fn mmap | |
102 | now returns with | |
103 | .Va errno | |
104 | set to EINVAL in places that historically succeeded. | |
105 | The rules have changed as follows: | |
106 | .Bl -bullet | |
107 | .It | |
108 | The | |
109 | .Fa flags | |
110 | parameter must specify either MAP_PRIVATE or MAP_SHARED. | |
111 | .It | |
112 | The | |
113 | .Fa size | |
114 | parameter must not be 0. | |
115 | .It | |
116 | The | |
117 | .Fa off | |
118 | parameter must be a multiple of pagesize, | |
119 | as returned by | |
120 | .Fn sysconf . | |
121 | .El | |
122 | .Sh SEE ALSO | |
123 | .Xr mmap 2 , | |
124 | .Xr alloca 3 , | |
125 | .Xr calloc 3 , | |
126 | .Xr free 3 , | |
127 | .Xr malloc 3 , | |
128 | .Xr realloc 3 , | |
129 | .Xr compat 5 | |
130 | .Sh STANDARDS | |
131 | These functions, with the exception of | |
132 | .Fn alloca | |
133 | and | |
134 | .Fn mmap | |
135 | conform to | |
136 | .St -isoC . |