Changeset View
Changeset View
Standalone View
Standalone View
head/share/man/man9/malloc.9
Show All 39 Lines | |||||
.Nm MALLOC_DEFINE , | .Nm MALLOC_DEFINE , | ||||
.Nm MALLOC_DECLARE | .Nm MALLOC_DECLARE | ||||
.Nd kernel memory management routines | .Nd kernel memory management routines | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In sys/types.h | .In sys/types.h | ||||
.In sys/malloc.h | .In sys/malloc.h | ||||
.Ft void * | .Ft void * | ||||
.Fn malloc "unsigned long size" "struct malloc_type *type" "int flags" | .Fn malloc "unsigned long size" "struct malloc_type *type" "int flags" | ||||
.Ft void * | |||||
.Fn mallocarray "size_t nmemb" "size_t size" "struct malloc_type *type" "int flags" | |||||
.Ft void | .Ft void | ||||
.Fn free "void *addr" "struct malloc_type *type" | .Fn free "void *addr" "struct malloc_type *type" | ||||
.Ft void * | .Ft void * | ||||
.Fn realloc "void *addr" "unsigned long size" "struct malloc_type *type" "int flags" | .Fn realloc "void *addr" "unsigned long size" "struct malloc_type *type" "int flags" | ||||
.Ft void * | .Ft void * | ||||
.Fn reallocf "void *addr" "unsigned long size" "struct malloc_type *type" "int flags" | .Fn reallocf "void *addr" "unsigned long 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 | ||||
.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 mallocarray | |||||
function allocates uninitialized memory in kernel address space for an | |||||
array of | |||||
.Fa nmemb | |||||
entries whose size is specified by | |||||
.Fa size . | |||||
.Pp | |||||
The | |||||
.Fn free | .Fn free | ||||
function releases memory at address | function releases memory at address | ||||
.Fa addr | .Fa addr | ||||
that was previously allocated by | that was previously allocated by | ||||
.Fn malloc | .Fn malloc | ||||
for re-use. | for re-use. | ||||
The memory is not zeroed. | The memory is not zeroed. | ||||
If | If | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
.Fn realloc , | .Fn realloc , | ||||
and | and | ||||
.Fn reallocf | .Fn reallocf | ||||
functions cannot return | functions cannot return | ||||
.Dv NULL | .Dv NULL | ||||
if | if | ||||
.Dv M_WAITOK | .Dv M_WAITOK | ||||
is specified. | is specified. | ||||
The | |||||
.Fn mallocarray | |||||
function can return | |||||
.Dv NULL | |||||
if the multiplication of | |||||
.Fa nmemb | |||||
and | |||||
.Fa size | |||||
would cause an integer overflow. | |||||
.It Dv M_USE_RESERVE | .It Dv M_USE_RESERVE | ||||
Indicates that the system can use its reserve of memory to satisfy the | Indicates that the system can use its reserve of memory to satisfy the | ||||
request. | request. | ||||
This option should only be used in combination with | This option should only be used in combination with | ||||
.Dv M_NOWAIT | .Dv M_NOWAIT | ||||
when an allocation failure cannot be tolerated by the caller without | when an allocation failure cannot be tolerated by the caller without | ||||
catastrophic effects on the system. | catastrophic effects on the system. | ||||
.El | .El | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |