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