[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

xmfree Kernel Service

Purpose

Frees allocated memory.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/malloc.h>
int xmfree (ptr, heap)
caddr_t ptr;
caddr_t heap;

Parameters

ptr Specifies the address of the area in memory to free.
heap Specifies the address of the heap from which the memory was allocated.

Description

The xmfree kernel service frees the area of memory pointed to by the ptr parameter in the heap specified by the heap parameter. This area of memory must be allocated with the xmalloc kernel service. In addition, the ptr pointer must be the pointer returned from the corresponding xmalloc call.

For example, the xmfree (ptr, kernel_heap) kernel service frees the area in the kernel heap allocated by ptr=xmalloc (size, align, kernel_heap).

A kernel extension must explicitly free any memory it allocates. If it does not, eventually subsequent allocations are unsuccessful. Pinned memory must also be unpinned before it is freed if allocated from the kernel_heap. The kernel does not keep track of which kernel extension owns various allocated areas in the heap. Therefore, the kernel never automatically frees these allocated areas on process termination or device close.

An additional interface to the xmfree kernel service is provided. The free (ptr) is equivalent to xmfree (ptr, kernel_heap).

Execution Environment

The xmfree kernel service can be called from the process environment only.

Return Values

0 Indicates successful completion.
-1 Indicates one of the following errors:
  • The area to be freed was not allocated with the xmalloc kernel service.
  • The heap was not initialized for memory allocation.

Implementation Specifics

The xmfree kernel service is part of Base Operating System (BOS) Runtime.

Related Information

The xmalloc kernel service.

Memory Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]