iree/hal/buffer_heap.c
static iree_status_t iree_hal_heap_buffer_allocate_slab(
    iree_device_size_t allocation_size, iree_allocator_t host_allocator,
    iree_hal_heap_buffer_t** out_buffer, iree_byte_span_t* out_data) {
  // NOTE: we want the buffer data to always be 16-byte aligned.
  iree_hal_heap_buffer_t* buffer = NULL;
  iree_host_size_t header_size =
      iree_host_align(iree_sizeof_struct(*buffer), 16);
  iree_host_size_t total_size = header_size + allocation_size;
  IREE_RETURN_IF_ERROR(
      iree_allocator_malloc(host_allocator, total_size, (void**)&buffer));
  *out_buffer = buffer;
  *out_data =
      iree_make_byte_span((uint8_t*)buffer + header_size, allocation_size);
  return iree_ok_status();
}
// Allocates a buffer with the metadata as a prefix to the storage.
// This results in a single allocation per buffer but requires that both the
// metadata and storage live together.
Allocates a buffer with the metadata as a prefix to the storage.
This results in a single allocation per buffer but requires that both the
metadata and storage live together.
Allocates a buffer with the metadata as a prefix to the storage . This results in a single allocation per buffer but requires that both the metadata and storage live together .
static iree_status_t iree_hal_heap_buffer_allocate_slab(
    iree_device_size_t allocation_size, iree_allocator_t host_allocator,
    iree_hal_heap_buffer_t** out_buffer, iree_byte_span_t* out_data) {
  iree_hal_heap_buffer_t* buffer = NULL;
  iree_host_size_t header_size =
      iree_host_align(iree_sizeof_struct(*buffer), 16);
  iree_host_size_t total_size = header_size + allocation_size;
  IREE_RETURN_IF_ERROR(
      iree_allocator_malloc(host_allocator, total_size, (void**)&buffer));
  *out_buffer = buffer;
  *out_data =
      iree_make_byte_span((uint8_t*)buffer + header_size, allocation_size);
  return iree_ok_status();
}
static iree_status_t iree_hal_heap_buffer_allocate_slab ( iree_device_size_t allocation_size , iree_allocator_t host_allocator , iree_hal_heap_buffer_t * * out_buffer , iree_byte_span_t * out_data ) { iree_hal_heap_buffer_t * buffer = NULL ; iree_host_size_t header_size = iree_host_align ( iree_sizeof_struct ( * buffer ) , 16 ) ; iree_host_size_t total_size = header_size + allocation_size ; IREE_RETURN_IF_ERROR ( iree_allocator_malloc ( host_allocator , total_size , ( void * * ) & buffer ) ) ; * out_buffer = buffer ; * out_data = iree_make_byte_span ( ( uint8_t * ) buffer + header_size , allocation_size ) ; return iree_ok_status ( ) ; }
Allocates a buffer with the metadata as a prefix to the storage.
Allocates a buffer with the metadata as a prefix to the storage .
// NOTE: we want the buffer data to always be 16-byte aligned.