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