IC4_ALLOCATOR_CALLBACKS Struct Reference

Contains function pointers used to configure a custom allocator for image buffers. More...

Data Fields

void(*  release )(void *context)

Notifies the user that the allocator will not receive any additional callback function calls.

bool(*  allocate_buffer )(void *context, size_t buffer_size, size_t alignment, void **buffer_ptr, void **user_data)

Requests the allocator to allocate a memory buffer.

void(*  free_buffer )(void *context, void *buffer_ptr, void *user_data

Requests the allocator to free a previously-allocated memory buffer.

Detailed Description

Contains function pointers used to configure a custom allocator for image buffers.

Field Documentation

◆ allocate_buffer

bool(* allocate_buffer) (void *context, size_t buffer_size, size_t alignment, void **buffer_ptr, void **user_data)

Requests the allocator to allocate a memory buffer.

Parameters
[in]contextThe allocator_context parameter that was passed to the sink creation function
[in]buffer_sizeThe size of the requested memory buffer
[in]alignmentRequests memory to be allocated on a specific alignment boundary.
This value is always a power of 2.
[out]buffer_ptrA pointer to a pointer that receives the address of the newly-allocated buffer
[out]user_dataUser data to attach to the buffer. The user data is passed to free_buffer when the allocated memory is freed again.
Returns
true on success. If the allocation could not be performed, return false.

◆ free_buffer

void(* free_buffer) (void *context, void *buffer_ptr, void *user_data)

Requests the allocator to free a previously-allocated memory buffer.

Parameters
[in]contextThe allocator_context parameter that was passed to the sink creation function
[in]buffer_ptrPointer to the memory buffer to be freed
[in]user_dataThe user data that was returned from allocate_buffer when the memory buffer was allocated

◆ release

void(* release) (void *context)

Notifies the user that the allocator will not receive any additional callback function calls.

Any resources attached to the context parameter can be released.

Parameters
[in]contextThe allocator_context parameter that was passed to the sink creation function.
Note
The release callback function is executed on the thread that destroys the sink using the final call to ic4_sink_unref().