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 June 13, 2018 | .Dd October 28, 2018 | ||||
.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 , | ||||
.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 "size_t size" "struct malloc_type *type" "int flags" | .Fn malloc "size_t size" "struct malloc_type *type" "int flags" | ||||
.Ft void * | .Ft void * | ||||
.Fn malloc_domain "size_t size" "struct malloc_type *type" "int domain" "int flags" | |||||
.Ft void * | |||||
.Fn mallocarray "size_t nmemb" "size_t size" "struct malloc_type *type" "int flags" | .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 | |||||
.Fn free_domain "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" | ||||
.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/domainset.h | |||||
.Ft void * | |||||
.Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" | |||||
.Ft void | |||||
.Fn free_domain "void *addr" "struct malloc_type *type" | |||||
.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_domain | .Fn malloc_domainset | ||||
variant allocates the object from the specified memory domain. Memory allocated | variant allocates memory from a specific | ||||
with this function should be returned with | .Xr numa 4 | ||||
.Fn free_domain . | domain using the specified domain selection policy. | ||||
See | See | ||||
.Xr numa 9 for more details. | .Xr domainset 9 | ||||
for some example policies. | |||||
Memory allocated with this function should be returned with | |||||
.Fn free_domain . | |||||
.Pp | .Pp | ||||
The | The | ||||
.Fn mallocarray | .Fn mallocarray | ||||
function allocates uninitialized memory in kernel address space for an | function allocates uninitialized memory in kernel address space for an | ||||
array of | array of | ||||
.Fa nmemb | .Fa nmemb | ||||
entries whose size is specified by | entries whose size is specified by | ||||
.Fa size . | .Fa size . | ||||
▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | |||||
such things as writing outside the allocated area and imbalanced calls to the | such things as writing outside the allocated area and imbalanced calls to the | ||||
.Fn malloc | .Fn malloc | ||||
and | and | ||||
.Fn free | .Fn free | ||||
functions. | functions. | ||||
Failing consistency checks will cause a panic or a system console | Failing consistency checks will cause a panic or a system console | ||||
message. | message. | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr numa 4 , | |||||
.Xr vmstat 8 , | .Xr vmstat 8 , | ||||
.Xr contigmalloc 9 , | .Xr contigmalloc 9 , | ||||
.Xr domainset 9 , | |||||
.Xr memguard 9 , | .Xr memguard 9 , | ||||
.Xr vnode 9 | .Xr vnode 9 |