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);..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 11: Line 11:


==Parameters==
==Parameters==
; ptr (somToken) : A pointer to the previously allocated region of memory. If NULL, a new region of memory of size bytes is allocated.  
;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.
; size (size_t) : The size in bytes for the re-allocated storage. If zero, the memory pointed to by  
ptr is freed.  


==Return Code==
==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.)  
;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==
==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 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  
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.
SOMRealloc.  


==Example Code==
==Example Code==
<PRE>
</PRE>


==Related==
==Related Functions==
===Functions===
* [[SOMCalloc]]
* [[SOMCalloc]]
* [[SOMMalloc]]  
* [[SOMMalloc]]
* [[SOMFree]]  
* [[somFree]]


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

Latest revision as of 16:24, 12 October 2022

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