Manpages - reallocf.3bsd

(See

for include usage.)

The

function changes the size of the previously allocated memory referenced by

to

bytes. The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the contents of the newly allocated portion of the memory are undefined. Upon success, the memory referenced by

is freed and a pointer to the newly allocated memory is returned. Note that

may move the memory allocation, resulting in a different return value than

If

is

the

function behaves identically to

for the specified size. Upon failure, when the requested memory cannot be allocated, the passed pointer is freed to ease the problems with traditional coding styles for

causing memory leaks in libraries.

The

function returns a pointer, possibly identical to

to the allocated memory if successful; otherwise a

pointer is returned, and

is set to

if the error was the result of an allocation failure. The buffer is deallocated in this case.

The

function first appeared in

Author: dt

Created: 2022-02-20 Sun 18:46