Next | Prev | Up | Top | Contents | Index

Allocating in a Shared Arena

Allocating shared memory from a shared arena is much like the regular process of allocating memory using the malloc() and free() library routines. A full set of memory-management functions is available for use with shared arenas, including:

void *usmalloc (size_t size,
usptr_t *handle);
Allocate size bytes in arena *handle.
void *usmemalign (size_t align,
size_t size, usptr_t *handle);
Allocate size bytes on an align boundary in arena *handle.
void *uscalloc (size_t nelem,
size_t elsize, usptr_t *handle);
Allocate nelem zero-filled adjacent units of size elsize in arena *handle.
void *usrealloc (void *ptr,
size_t size, usptr_t *handle);
Change the size of object *ptr in arena *handle to size.
void usfree (void *ptr,
usptr_t *handle);
Release object at *ptr in arena *handle.

See the usmalloc(3P) reference page for details and additional functions.

The address of an object allocated using usmalloc() or a related function is a valid address in any process that is attached to the shared arena. If the address is passed to a process that has not attached the arena, the address is not valid for that process and its use causes a SIGSEGV.

The usmalloc() family of functions is based on the arena-allocation function family described in the amalloc(3P) reference page. The usmallopt() function is the same as the amallopt() function, and both provide several options for modifying the memory allocation methods in a particular arena. In a similar way, usmallinfo() is the same as amallinfo(), and both return detailed statistics on usage of memory allocation in one arena.


Next | Prev | Up | Top | Contents | Index