Jump to content

SOMRealloc: Difference between revisions

From EDM2
Created page with "This function changes the size of a previously allocated region of memory. ==Syntax== <PRE> somToken ptr; size_t size; somToken rc; rc = (*SOMRealloc)(ptr, size);..."
 
Line 32: Line 32:
* [[SOMCalloc]]
* [[SOMCalloc]]
* [[SOMMalloc]]  
* [[SOMMalloc]]  
* [[SOMFree]]  
* [[somFree]]  


[[Category:SOM Kernel]]
[[Category:SOM Kernel]]

Revision as of 19:37, 10 October 2017

This function changes the size of a previously allocated region of memory.

Syntax

somToken    ptr;
size_t      size;
somToken    rc;

rc = (*SOMRealloc)(ptr, size);

Parameters

ptr (somToken)
A pointer to the previously allocated region of memory. If NULL, a new region of memory of size bytes is allocated.
size (size_t)
The size in bytes for the re-allocated storage. If zero, the memory pointed to by

ptr is freed.

Return Code

rc (somToken)
A pointer to the first byte of the re-allocated space. (A pointer is returned because the block of storage may need to be moved to increase its size.)

Remarks

The SOMRealloc function changes the size of the previously allocated region of memory pointed to by ptr so that it contains size bytes. The new size may be greater or less than the original size. The SOMRealloc function has the same interface as the C realloc function. It performs the same basic function as realloc with some supplemental error checking. If an error occurs, the SOMError function is called. This routine is replaceable by changing the value of the global variable SOMRealloc.

Example Code


Related

Functions