Next Previous Contents

## 3.126 realloc

> Function

>   Change the size of an allocated memory block.

> Header

>   `stdlib.h`

> Declaration

>   `void* __fastcall__ realloc (void* block, size_t size);`

> Description

>   `realloc` changes the size of the memory block pointed to by `block` to `size` bytes. If `block` is `NULL`, `realloc` behaves as if `malloc` had been called. If `size` is zero, `realloc` behaves as if `free` had been called. On error (not enough memory available), `realloc` returns `NULL`.

> Limits

>   - The part of the memory block that is returned will have its contents unchanged.
>   - This function is somewhat dangerous to use. Be careful to save the pointer you're passing somewhere else, otherwise

>     > `

>     >             ptr = realloc (ptr, size);

>     > `

>     will loose your only copy of `ptr` if `realloc` returns `NULL`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, _heapmemavail, calloc, free, realloc

> Example

>   None.

Next Previous Contents