3.11.7 omp_free – Freeing memory allocated with OpenMP routines

Description:

The omp_free routine deallocates memory previously allocated by an OpenMP memory-management routine. The ptr argument must point to such memory or be a null pointer; if it is a null pointer, no operation is performed. If specified, the allocator argument must be either the memory allocator that was used for the allocation or omp_null_allocator; if it is omp_null_allocator, the implementation will determine the value automatically.

Calling omp_free invokes undefined behavior if the memory was already deallocated or when the used allocator has already been destroyed.

C:
Prototype:void omp_free(void *ptr,
omp_allocator_handle_t allocator)
C++:
Prototype:void omp_free(void *ptr,
omp_allocator_handle_t allocator=omp_null_allocator)
Fortran:
Interface:subroutine omp_free(ptr, allocator) bind(C)
use, intrinsic :: iso_c_binding, only : c_ptr
type (c_ptr), value :: ptr
integer (omp_allocator_handle_kind), value :: allocator
See also:

omp_alloc – Memory allocation with an allocator, omp_aligned_alloc – Memory allocation with an allocator and alignment, omp_calloc – Allocate nullified memory with an allocator, omp_aligned_calloc – Allocate aligned nullified memory with an allocator, omp_realloc – Reallocate memory allocated with OpenMP routines

Reference:

OpenMP specification v5.0, Section 3.7.7