remalloc

Description:

With remalloc the kernel implements the support for dynamic memory block resizing. remalloc assigns the specified memory block a new size within the range specified when the memory block was allocated with malloc. If the free system memory becomes low, a reserved block can be used by the kernel to provide memory space for other processes. In this case further calls to remalloc to enlarge this memory block with its reserved memory block will fail as the reserved block has not the PID of a reserved block anymore but the PID of the process owning it.

Function Prototype:

void * remalloc (void * object, MEMVAR size);;

Parameters:

object

A pointer to the beginning of the memory block to be resized. If the pointer is NULL or invalid (e.g. the memory block belongs to a different process) the call will fail and the function returns a NULL-pointer. The process should then call getlasterror to get extended error information.

size

Memory variable specifying the new size of the memory block. This value can be either larger or smaller as the current size of the memory block. The size can be at smallest zero. At largest it can have the size of the of the sum of the memory block size and reserved memory block size specified when the memory block was allocated with malloc. If the requested size is larger, the call will fail and the function returns a NULL-pointer.

Return Values:

If remalloc could successfully reallocate the demanded size of memory from the free system memory it will return a pointer to the beginning of the reallocated memory block. In case of failure it will return a NULL pointer, the process should then call getlasterror to receive extended information on the allocating failure.


See also malloc, memset, free, getfreemem, getreservedmem, getusedmem, getlasterror