omp_realloc
Purpose
The omp_realloc function deallocates previously allocated memory and requests a memory allocation from a memory allocator.
Prototype
"void *omp_realloc(void *ptr, size_t size,
omp_allocator_handle_t allocator, omp_allocator_handle_t
free_allocator);"
"void *omp_realloc(void *ptr, size_t size,
omp_allocator_handle_t allocator=omp_null_allocator, omp_allocator_handle_t
free_allocator=omp_null_allocator);"
Parameter
- ptr
- Points to the memory that this routine deallocates. ptr must have been returned by an OpenMP allocation function.
- size
- Specifies the bytes of the new memory allocation that this routine requests.
- allocator
- Specifies an OpenMP memory allocator.
- free_allocator
- If the free_allocator is specified, it must be the memory allocator to which the previous allocation request was made.
Usage
This function deallocates the memory to which ptr points. Upon success this function returns a (possibly moved) pointer to the allocated memory and the contents of the new object shall be the same as that of the old object prior to deallocation, up to the minimum size of old allocated size and size. Any bytes in the new object beyond the old allocated size will have unspecified values. If the allocation failed, the behavior that the fallback trait of the allocator specifies will be followed.
If ptr is NULL, omp_realloc will behave the same as omp_alloc with the same size and allocator arguments.
If size is 0, omp_realloc will return NULL and the old allocation will be deallocated.
If size is not 0, the old allocation will be deallocated if and only if the function returns a non-NULL value. Memory allocated by omp_realloc will be byte-aligned to at least the maximum of the alignment required by malloc and the alignment trait of the allocator.
If you use omp_realloc on memory that was already deallocated or that was allocated by an allocator that has already been destroyed with omp_destroy_allocator, the behavior is unspecified.