xref: /freebsd/lib/libc/stdlib/memory.3 (revision 63f537551380d2dab29fa402ad1269feae17e594)
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. 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.\"
30.Dd October 18, 2023
31.Dt MEMORY 3
32.Os
33.Sh NAME
34.Nm aligned_alloc ,
35.Nm alloca ,
36.Nm calloc ,
37.Nm free ,
38.Nm malloc ,
39.Nm posix_memalign ,
40.Nm realloc ,
41.Nm reallocf ,
42.Nm valloc ,
43.Nm mmap ,
44.Nm munmap
45.Nd memory management functions
46.Sh LIBRARY
47.Lb libc
48.Sh SYNOPSIS
49.In stdlib.h
50.Ft void *
51.Fn aligned_alloc "size_t alignment" "size_t size"
52.Ft void *
53.Fn alloca "size_t size"
54.Ft void *
55.Fn calloc "size_t nelem" "size_t elsize"
56.Ft void
57.Fn free "void *ptr"
58.Ft void *
59.Fn malloc "size_t size"
60.Ft int
61.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size"
62.Ft void *
63.Fn realloc "void *ptr" "size_t size"
64.Ft void *
65.Fn reallocf "void *ptr" "size_t size"
66.Ft void *
67.Fn valloc "size_t size"
68.In sys/types.h
69.In sys/mman.h
70.Ft void *
71.Fn mmap "void * addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
72.Ft int
73.Fn munmap "void *addr" "size_t len"
74.Sh DESCRIPTION
75These functions allocate and free memory for the calling process.
76They are described in the
77individual manual pages.
78.Sh SEE ALSO
79.Xr mmap 2 ,
80.Xr aligned_alloc 3 ,
81.Xr alloca 3 ,
82.Xr calloc 3 ,
83.Xr free 3 ,
84.Xr malloc 3 ,
85.Xr posix_memalign 3 ,
86.Xr realloc 3 ,
87.Xr reallocf 3 ,
88.Xr valloc 3 ,
89.Sh STANDARDS
90The
91.Fn calloc ,
92.Fn free ,
93.Fn malloc ,
94and
95.Fn realloc
96functions conform to
97.St -isoC .
98.Pp
99The
100.Fn mmap ,
101.Fn munmap ,
102and
103.Fn posix_memalign
104functions conform to
105.St -p1003.1-2001 .
106