Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/malloc.9
Show All 23 Lines | |||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
.\" POSSIBILITY OF SUCH DAMAGE. | .\" POSSIBILITY OF SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $ | .\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $ | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd March 6, 2021 | .Dd July 2, 2021 | ||||
.Dt MALLOC 9 | .Dt MALLOC 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm malloc , | .Nm malloc , | ||||
.Nm free , | .Nm free , | ||||
.Nm realloc , | .Nm realloc , | ||||
.Nm reallocf , | .Nm reallocf , | ||||
.Nm MALLOC_DEFINE , | .Nm MALLOC_DEFINE , | ||||
Show All 12 Lines | |||||
.Fn zfree "void *addr" "struct malloc_type *type" | .Fn zfree "void *addr" "struct malloc_type *type" | ||||
.Ft void * | .Ft void * | ||||
.Fn realloc "void *addr" "size_t size" "struct malloc_type *type" "int flags" | .Fn realloc "void *addr" "size_t size" "struct malloc_type *type" "int flags" | ||||
.Ft void * | .Ft void * | ||||
.Fn reallocf "void *addr" "size_t size" "struct malloc_type *type" "int flags" | .Fn reallocf "void *addr" "size_t size" "struct malloc_type *type" "int flags" | ||||
.Ft size_t | .Ft size_t | ||||
.Fn malloc_usable_size "const void *addr" | .Fn malloc_usable_size "const void *addr" | ||||
.Ft void * | .Ft void * | ||||
.Fo malloc_aligned | |||||
.Fa "size_t size" | |||||
.Fa "size_t align" | |||||
.Fa "struct malloc_type *type" | |||||
.Fa "int flags" | |||||
.Fc | |||||
.Ft void * | |||||
.Fn malloc_exec "size_t size" "struct malloc_type *type" "int flags" | .Fn malloc_exec "size_t size" "struct malloc_type *type" "int flags" | ||||
.Fn MALLOC_DECLARE type | .Fn MALLOC_DECLARE type | ||||
.In sys/param.h | .In sys/param.h | ||||
.In sys/malloc.h | .In sys/malloc.h | ||||
.In sys/kernel.h | .In sys/kernel.h | ||||
.Fn MALLOC_DEFINE type shortdesc longdesc | .Fn MALLOC_DEFINE type shortdesc longdesc | ||||
.In sys/param.h | .In sys/param.h | ||||
.In sys/domainset.h | .In sys/domainset.h | ||||
.Ft void * | .Ft void * | ||||
.Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | .Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | ||||
.Ft void * | .Ft void * | ||||
.Fo malloc_domainset_aligned | |||||
kib: You can use .Fo to avoid this long line | |||||
.Fa "size_t size" | |||||
.Fa "size_t align" | |||||
.Fa "struct malloc_type *type" | |||||
.Fa "struct domainset *ds" | |||||
.Fa "int flags" | |||||
.Fc | |||||
.Ft void * | |||||
.Fn malloc_domainset_exec "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | .Fn malloc_domainset_exec "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | ||||
.Ft void * | .Ft void * | ||||
.Fn mallocarray_domainset "size_t nmemb" "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | .Fn mallocarray_domainset "size_t nmemb" "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Fn malloc | .Fn malloc | ||||
function allocates uninitialized memory in kernel address space for an | function allocates uninitialized memory in kernel address space for an | ||||
object whose size is specified by | object whose size is specified by | ||||
.Fa size . | .Fa size . | ||||
.Pp | .Pp | ||||
The | The | ||||
.Fn malloc_domainset | .Fn malloc_domainset | ||||
variant allocates memory from a specific | variant allocates memory from a specific | ||||
.Xr numa 4 | .Xr numa 4 | ||||
domain using the specified domain selection policy. | domain using the specified domain selection policy. | ||||
See | See | ||||
.Xr domainset 9 | .Xr domainset 9 | ||||
for some example policies. | for some example policies. | ||||
.Pp | |||||
The | |||||
.Fn malloc_aligned | |||||
and | |||||
.Fn malloc_domainset_aligned | |||||
variants return allocations aligned as specified by | |||||
Done Inline ActionsIt would be useful to note that:
kib: It would be useful to note that:
- align should be non-zero and power of two
- we only support… | |||||
.Fa align , | |||||
which must be non-zero, a power of two, and less than or equal to the page size. | |||||
.Pp | .Pp | ||||
Both | Both | ||||
.Fn malloc_exec | .Fn malloc_exec | ||||
and | and | ||||
.Fn malloc_domainset_exec | .Fn malloc_domainset_exec | ||||
can be used to return executable memory. | can be used to return executable memory. | ||||
Not all platforms enforce a distinction between executable and non-executable memory. | Not all platforms enforce a distinction between executable and non-executable memory. | ||||
.Pp | .Pp | ||||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |
You can use .Fo to avoid this long line