valloc() — Page-aligned memory allocator

Standards

Standards / Extensions C or C++ Dependencies
XPG4.2 both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <stdlib.h>

void *valloc(size_t size);

General description

Restriction: This function is not supported in AMODE 64.

The valloc() function has the same effect as malloc(), except that the allocated memory will be aligned to a multiple of the value returned by sysconf(_SC_PAGESIZE).

Note: When free() is used to release storage obtained by valloc(), the storage is not made available for reuse. The storage will not be freed until the enclave goes away.

Special behavior for C++: The C++ keywords new and delete are not interoperable with valloc(), calloc(), free(), malloc(), or realloc().

Note:

This function is kept for historical reasons. It was part of the Legacy Feature in Single UNIX Specification, Version 2, but has been withdrawn and is not supported as part of Single UNIX Specification, Version 3. The malloc() or mmap() functions are preferred for portability.

If it is necessary to continue using this function in an application written for Single UNIX Specification, Version 3, define the feature test macro _UNIX03_WITHDRAWN before including any standard system headers. The macro exposes all interfaces and symbols removed in Single UNIX Specification, Version 3.

Returned value

If successful, valloc() returns a pointer to the reserved storage. The storage space to which the returned value points is guaranteed to be aligned on a page boundary.

If unsuccessful, valloc() returns NULL if there is not enough storage available, or if size is 0. If valloc() returns NULL because there is not enough storage, it sets errno to one of the following values:
Error Code
Description
ENOMEM
Insufficient memory is available

Related information