Dynamically Allocating and De-allocating Memory

For several functions of the Rexx-API it is necessary or possible to dynamically allocate or free memory. Depending on the operating system, compiler and REXX interpreter, the method for these allocations and de- allocations vary. To write system independent code, Object REXX comes with two API function calls called RexxAllocateMemory() and RexxFreeMemory(). These functions are wrapper for the corresponding compiler or operating system memory functions.

The RexxAllocateMemory() Function

void * REXXENTRY RexxAllocateMemory( size_t size );



is the number of bytes of requested memory.

Return Codes

Returns a pointer to the newly allocated block of memory, or NULL if no memory could be allocated.

The RexxFreeMemory() Function

RexxReturnCode REXXENTRY RexxFreeMemory( void *MemoryBlock );



is a void pointer to the block of memory allocated by the Object REXX interpreter, or allocated by a previous call to RexxAllocateMemory().

Return Codes

RexxFreeMemory() always returns 0.