malloc.3c (2010 09)

m
malloc(3C) malloc(3C)
available for further allocation. If ptr is a NULL pointer, no action occurs.
mallopt() Provides for control over the allocation algorithm and other options in the
mal-
loc() package. The available values for cmd are:
M_MXFAST Set maxfast to value . The algorithm allocates all blocks below the
size of maxfast in large groups, then doles them out very quickly.
The default value for maxfast is zero.
M_NLBLKS Set numlblks to value . The above mentioned ‘‘large groups’’ each
contain numlblks blocks. numlblks must be greater than 1. The
default value for numlblks is 100.
M_GRAIN Set grain to value . The sizes of all blocks smaller than maxfast are
considered to be rounded up to the nearest multiple of grain . grain
must be greater than zero. The default value of grain is the smal-
lest number of bytes that can accommodate alignment of any data
type. value is rounded up to a multiple of the default when grain is
set.
M_BLOCK Block all blockable signals in malloc(),
realloc(), cal-
loc(), and free(). This option is provided for those who need
to write signal handlers that allocate memory. When set, the mal-
loc() routines can be called from within signal handlers (they
become re-entrant). Default action is not to block all blockable sig-
nals.
NOTE: performance of
malloc() will be impacted considerably
when the M_BLOCK option is set.
M_UBLOCK Do not block all blockable signals in malloc(), realloc(),
calloc(), and free(). This option cancels signal blocking ini-
tiated by the M_BLOCK option.
M_REL_LAST_FBLK
Enable the feature of release last free block to heap . This option is
provided for 32-bit applications with one arena. Release of last
block happens only when size of the free block is greater than the
threshold.
The threshold value is defined as
2 * (arena expansion
factor) * 4096 bytes. The feature is disabled if the
M_MXFAST value is greater than or equal to threshold value.
Default action is not to release last block.
These values are defined in the
<malloc.h> header file.
mallopt() can be called repeatedly; but once the first small block is allocated, it
is not possible to change the M_MAXFAST, M_NLBLKS, and M_GRAIN values.
mallinfo() Provides instrumentation describing space usage, but cannot be called until the first
small block is allocated. It returns the structure mallinfo:
arena : total space in arena
fsmblks : number of bytes in free small blocks
fordblks : number of bytes in free ordinary blocks
hblks : number of holding blocks
hblkhd : number of bytes in holding block headers
keepcost : cost of enabling keep option
ordblks : number of ordinary blocks
smblks : number of small blocks
uordblks : number of bytes in ordinary blocks in use
usmblks : number of bytes in small blocks in use
The mallinfo structure is defined in the <malloc.h> header file.
Each of the allocation routines returns a pointer to space suitably aligned (after possible pointer coercion)
for storage of any type of object.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010