iree/hal/buffer_heap.c
static iree_status_t iree_hal_heap_buffer_allocate_split(
    iree_device_size_t allocation_size, iree_allocator_t data_allocator,
    iree_allocator_t host_allocator, iree_hal_heap_buffer_t** out_buffer,
    iree_byte_span_t* out_data) {
  // Try allocating the storage first as it's the most likely to fail if OOM.
  out_data->data_length = allocation_size;
  IREE_RETURN_IF_ERROR(iree_allocator_malloc(data_allocator, allocation_size,
                                             (void**)&out_data->data));

  // Allocate the host metadata wrapper.
  iree_status_t status = iree_allocator_malloc(
      host_allocator, sizeof(**out_buffer), (void**)out_buffer);
  if (!iree_status_is_ok(status)) {
    // Need to free the storage we just allocated.
    iree_allocator_free(data_allocator, out_data->data);
  }
  return status;
}
// Allocates a buffer with the metadata and storage split.
// This results in an additional host allocation but allows for user-overridden
// data storage allocations.
Allocates a buffer with the metadata and storage split.
This results in an additional host allocation but allows for user-overridden
data storage allocations.
Allocates a buffer with the metadata and storage split . This results in an additional host allocation but allows for user - overridden data storage allocations .
static iree_status_t iree_hal_heap_buffer_allocate_split(
    iree_device_size_t allocation_size, iree_allocator_t data_allocator,
    iree_allocator_t host_allocator, iree_hal_heap_buffer_t** out_buffer,
    iree_byte_span_t* out_data) {
  out_data->data_length = allocation_size;
  IREE_RETURN_IF_ERROR(iree_allocator_malloc(data_allocator, allocation_size,
                                             (void**)&out_data->data));
  iree_status_t status = iree_allocator_malloc(
      host_allocator, sizeof(**out_buffer), (void**)out_buffer);
  if (!iree_status_is_ok(status)) {
    iree_allocator_free(data_allocator, out_data->data);
  }
  return status;
}
static iree_status_t iree_hal_heap_buffer_allocate_split ( iree_device_size_t allocation_size , iree_allocator_t data_allocator , iree_allocator_t host_allocator , iree_hal_heap_buffer_t * * out_buffer , iree_byte_span_t * out_data ) { out_data -> data_length = allocation_size ; IREE_RETURN_IF_ERROR ( iree_allocator_malloc ( data_allocator , allocation_size , ( void * * ) & out_data -> data ) ) ; iree_status_t status = iree_allocator_malloc ( host_allocator , sizeof ( * * out_buffer ) , ( void * * ) out_buffer ) ; if ( ! iree_status_is_ok ( status ) ) { iree_allocator_free ( data_allocator , out_data -> data ) ; } return status ; }
Allocates a buffer with the metadata and storage split.
Allocates a buffer with the metadata and storage split .
// Try allocating the storage first as it's the most likely to fail if OOM. // Allocate the host metadata wrapper. // Need to free the storage we just allocated.