Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (i - m) malloc_pages(3)
NAME
malloc_pages - Provides a memory page allocator
LIBRARY
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCREDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcredll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycredll
SYNOPSIS
#include <sys/types.h>
#include <stdlib.h>
void *malloc_pages (
size_t size );
PARAMETERS
size Specifies the number of bytes of memory to be allocated.
DESCRIPTION
The malloc_pages( ) function returns a pointer to a block of memory of at least the number of
bytes specified by the size parameter. The block is aligned so that it can be used for any type of
data. The space allocated is always a multiple of pages. That is, the number of bytes requested
for the space is rounded up to a multiple of the page size so that the allocated space always occu-
pies 1 or more complete pages.
If the size parameter is 0 (zero), the function returns a null pointer.
The malloc_pages( ) function behaves like malloc( ), except that the allocated memory is
automatically aligned to a page boundary (that is, aligned to the value returned by a call to get-
pagesize( )).
The malloc_pages( ) function can be called by TNS/E native processes only.
RETURN VALUES
This allocation function returns a pointer to space suitably aligned for storage of any type of
object. Cast the pointer to the type pointer-to-element before using it.
The malloc_pages( ) function returns a null pointer if there is no available memory or if the
memory area has been corrupted by storing outside the bounds of a block. When this happens,
the block pointed to by the pointer parameter could be destroyed.
ERRORS
If any of the following conditions occurs, the malloc_pages( ) function sets errno to the
corresponding value:
[ENOMEM] There is not enough storage memory in the system.
RELATED INFORMATION
Functions: calloc(3), free(3), getpagesize(3), malloc(3), realloc(3), valloc(3).
STANDARDS CONFORMANCE
The malloc_pages( ) function is an HP extension to the UNIX 98 specification.
527187-017 Hewlett-Packard Company 4173