typedef ompd_rc_t (*ompd_callback_memory_alloc_fn_t) (
ompd_size_t nbytes,
void **ptr
);
The OMPD library must not access the heap manager directly. Instead, if it needs heap memory it must use the memory allocation and deallocation callback functions that are described in this section, ompd_callback_memory_alloc_fn_t (see Section 5.4.1.1 on page 1513) and ompd_callback_memory_free_fn_t (see Section 5.4.1.2 on page 1515), which are provided by the tool to obtain and to release heap memory. This mechanism ensures that the library does not interfere with any custom memory management scheme that the tool may use.
If the OMPD library is implemented in C++, memory management operators like new and delete in all their variants, must all be overloaded and implemented in terms of the callbacks that the tool provides. The OMPD library must be coded so that any of its definitions of new or delete do not interfere with any that the tool defines.
In some cases, the OMPD library must allocate memory to return results to the tool. The tool then owns this memory and has the responsibility to release it. Thus, the OMPD library and the tool must use the same memory manager.
The OMPD library creates OMPD handles, which are opaque to the tool and may have a complex internal structure. The tool cannot determine if the handle pointers that the API returns correspond to discrete heap allocations. Thus, the tool must not simply deallocate a handle by passing an address that it receives from the OMPD library to its own memory manager. Instead, the API includes functions that the tool must use when it no longer needs a handle.
A tool creates contexts and passes them to the OMPD library. The OMPD library does not release contexts; instead the tool release them after it releases any handles that may reference the contexts.
SummaryThe ompd_callback_memory_alloc_fn_t type is the type signature of the callback routine that the tool provides to the OMPD library to allocate memory.
DescriptionThe ompd_callback_memory_alloc_fn_t type is the type signature of the memory allocation callback routine that the tool provides. The OMPD library may call the ompd_callback_memory_alloc_fn_t callback function to allocate memory.
Description of ArgumentsThe nbytes argument is the size in bytes of the block of memory to allocate. The address of the newly allocated block of memory is returned in the location to which the ptr argument points. The newly allocated block is suitably aligned for any type of variable, and is not guaranteed to be zeroed.
SummaryThe ompd_callback_memory_free_fn_t type is the type signature of the callback routine that the tool provides to the OMPD library to deallocate memory.
DescriptionThe ompd_callback_memory_free_fn_t type is the type signature of the memory deallocation callback routine that the tool provides. The OMPD library may call the ompd_callback_memory_free_fn_t callback function to deallocate memory that was obtained from a prior call to the ompd_callback_memory_alloc_fn_t callback function.
Description of ArgumentsThe ptr argument is the address of the block to be deallocated.