|
Purpose |
Reallocates a heap block with a new size | |
|
Syntax |
ANY PTR reallocx(ANY PTR ptr,size_t old_size,size_t new_size); | |
|
Parameters |
ANY PTR ptr |
Pointer to allocated heap area. Do not pass a pointer allocated through the function mallocp(); use only the function mallocx() |
|
|
size_t old_size |
Size of the old block |
|
|
size_t new_size |
Required size of the new block |
|
Description |
This function implements memory reallocation. The main limitation is that if the block has to be moved, the existing block is not freed until the new allocation has succeeded. So, the allocation may fail even if there is enough memory to satisfy the request. It behaves like this to preserve the existing block intact should the reallocation fail. | |
|
Return values |
If reallocx() succeeds, the old block is freed and a pointer to a block of memory of size new_size is returned. If it fails, 0 is returned and the old block of memory is preserved. | |
|
See also |
||