]> git.saurik.com Git - apple/libc.git/blame - stdlib/FreeBSD/memory.3
Libc-1044.1.2.tar.gz
[apple/libc.git] / stdlib / FreeBSD / 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.
e9ce8d39
A
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.\"
5b2abdfb 28.\" @(#)memory.3 8.1 (Berkeley) 6/4/93
1f2f436a 29.\" $FreeBSD: src/lib/libc/stdlib/memory.3,v 1.12 2007/01/09 00:28:10 imp Exp $
e9ce8d39 30.\"
5b2abdfb
A
31.Dd June 4, 1993
32.Dt MEMORY 3
e9ce8d39
A
33.Os
34.Sh NAME
5b2abdfb 35.Nm alloca ,
ad3c9f2a
A
36.Nm calloc ,
37.Nm free ,
38.Nm malloc ,
39.Nm mmap ,
40.Nm realloc
5b2abdfb 41.Nd general memory allocation operations
e9ce8d39
A
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
5b2abdfb
A
45.In stdlib.h
46.Ft void *
ad3c9f2a
A
47.Fo alloca
48.Fa "size_t size"
49.Fc
5b2abdfb 50.Ft void *
ad3c9f2a
A
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
5b2abdfb 59.Ft void *
ad3c9f2a
A
60.Fo malloc
61.Fa "size_t size"
62.Fc
5b2abdfb 63.Ft void *
ad3c9f2a
A
64.Fo realloc
65.Fa "void *ptr"
66.Fa "size_t size"
67.Fc
5b2abdfb
A
68.In sys/mman.h
69.Ft void *
ad3c9f2a
A
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
e9ce8d39 78.Sh DESCRIPTION
5b2abdfb
A
79These functions allocate and free memory for the calling process.
80They are described in the
81individual manual pages.
ad3c9f2a
A
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
97The include file
98.In sys/types.h
99is needed for this function.
100.Sh COMPATIBILITY
101.Fn mmap
102now returns with
103.Va errno
104set to EINVAL in places that historically succeeded.
105The rules have changed as follows:
106.Bl -bullet
107.It
108The
109.Fa flags
110parameter must specify either MAP_PRIVATE or MAP_SHARED.
111.It
112The
113.Fa size
114parameter must not be 0.
115.It
116The
117.Fa off
118parameter must be a multiple of pagesize,
119as returned by
120.Fn sysconf .
121.El
e9ce8d39 122.Sh SEE ALSO
5b2abdfb
A
123.Xr mmap 2 ,
124.Xr alloca 3 ,
125.Xr calloc 3 ,
126.Xr free 3 ,
127.Xr malloc 3 ,
ad3c9f2a
A
128.Xr realloc 3 ,
129.Xr compat 5
5b2abdfb
A
130.Sh STANDARDS
131These functions, with the exception of
132.Fn alloca
133and
134.Fn mmap
135conform to
136.St -isoC .