ec_realloc

March 26, 2020 Contributors

Name

ec_realloc — Re-allocate a block of memory, changing its size

Synopsis

#include "ec_malloc.h"

| void * **ec_realloc** ( | object_type, |   |
|   | old, |   |
|   | size); |   |

int <var class="pdparam">object_type</var>;
void * <var class="pdparam">old</var>;
size_t <var class="pdparam">size</var>;

Description

Re-allocate a block of memory, changing its size. This function returns NULL if the size could not be altered; the original pointer is left untouched in this case.

Note

This function is only valid with VSIZE memory type, not a fixed size type. For more information about memory types see Memory Types.

The "old" pointer must have been allocated against the same object_type as is being requested here, otherwise undefined behavior will result.

The commentary about mmap in the ec_malloc_size documentation also applies to ec_realloc.

It is illegal to attempt to realloc a fixed size allocation using this function. Undefined, and most certainly unwanted behavior, will result if this is attempted.

Memory returned from this function must be freed via ec_free.

Parameters

object_type

This parameter is an integer indicating a memory type as defined in the section called “Memory Types”.

old

A pointer to the original memory location.

size

A size_t type unsigned integer.

Return Values

This function returns the address of the newly sized memory block; it may be the same as the original pointer.

Threading

It is legal to call this function in any thread.

See Also

ec_malloc, ec_malloc_size, ec_free and ec_mt_strndup and ec_mt_strdup.